Feature #44642
closedInclude seconds in pasted image filenames so that they sort in paste order
Description
When an image is pasted from the clipboard into a wiki text area, Redmine generates a filename such as the following:
clipboard-202610191803-bm9uy.png
The timestamp has a resolution of one minute only, and it is followed by five random characters. When a user pastes several screenshots one after another within the same minute, for example to describe the steps to reproduce a problem, their order cannot be determined from their filenames. After the attachments are downloaded, they cannot be sorted in the order in which they were pasted. Sorting by modification time does not help either, because downloaded files usually have the download time as their modification time.
This patch adds seconds to the timestamp:
clipboard-20261019180359-bm9uy.png
Since a person rarely pastes images more than once a second, a resolution of one second is sufficient to keep manually pasted images in paste order.
Notes:
- Since the timestamp now includes seconds, I considered reducing the random part to three characters to keep the filename length unchanged. However, automated tools can paste dozens of images within a single second. With only three characters (46,656 combinations), the probability of a name collision would then reach a few percent, which is too high to ignore. The random part therefore keeps five characters.
- The regular expression that detects pasted images in getInlineAttachmentMarkup (used to set the display width of the image) is updated to match the new format.
Files
Updated by Go MAEDA 17 days ago
- File 0001-Add-a-system-test-for-pasting-an-image-from-the-clip.patch 0001-Add-a-system-test-for-pasting-an-image-from-the-clip.patch added
- File 0002-Include-seconds-in-pasted-image-filenames.patch 0002-Include-seconds-in-pasted-image-filenames.patch added
I have attached two patches that replace the previous one. The previous patch added test_pasted_image_filename_should_include_seconds, a system test whose only purpose was to check that the filename includes seconds. Since adding a system test just for that seemed excessive, I have instead added a test for the image paste feature itself, which had no test before, and the filename format is checked in that test.
- 0001-Add-a-system-test-for-pasting-an-image-from-the-clip.patch: Adds the test. It also checks that the inline markup includes the display width of the image. The width is added only when the filename matches the pattern in getInlineAttachmentMarkup, so this catches a mismatch between the generated filename and that pattern.
- 0002-Include-seconds-in-pasted-image-filenames.patch: Adds seconds to the filename and updates the test for the new format.