summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-04-07 05:30:01 +0000
committerGo MAEDA <maeda@farend.jp>2021-04-07 05:30:01 +0000
commitab3128106e643bd0bfb720ebb96c1671a78d2822 (patch)
tree384402f75dcf41938486aef0664fb3ea620fd51d
parent7fe7fdd7bc87a0e34225e66c91ab6583d6989f28 (diff)
downloadredmine-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.rb2
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