diff options
author | Go MAEDA <maeda@farend.jp> | 2021-04-07 05:30:01 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-04-07 05:30:01 +0000 |
commit | ab3128106e643bd0bfb720ebb96c1671a78d2822 (patch) | |
tree | 384402f75dcf41938486aef0664fb3ea620fd51d | |
parent | 7fe7fdd7bc87a0e34225e66c91ab6583d6989f28 (diff) | |
download | redmine-ab3128106e643bd0bfb720ebb96c1671a78d2822.tar.gz redmine-ab3128106e643bd0bfb720ebb96c1671a78d2822.zip |
The result of Attachment.latest_attach is unstable if attachments have the same timestamp (#34999).
Patch by Pavel Rosický.
git-svn-id: http://svn.redmine.org/redmine/trunk@20923 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/attachment.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 620ea89ef..241ed0d70 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -370,7 +370,7 @@ class Attachment < ActiveRecord::Base def self.latest_attach(attachments, filename) return unless filename.valid_encoding? - attachments.sort_by(&:created_on).reverse.detect do |att| + attachments.sort_by{|attachment| [attachment.created_on, attachment.id]}.reverse.detect do |att| filename.casecmp?(att.filename) end end |