Project

General

Profile

Actions

Feature #44642

closed

Include seconds in pasted image filenames so that they sort in paste order

Added by Go MAEDA 27 days ago. Updated 14 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Resolution:
Fixed

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

Actions #1

Updated by Go MAEDA 25 days ago

  • Target version set to 7.1.0

Setting the target version to 7.1.0.

Actions #2

Updated by Go MAEDA 17 days ago

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.
Actions #3

Updated by Go MAEDA 14 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patches in r25366 and r25367.

Actions

Also available in: Atom PDF