Skip to content

Commit ab31281

Browse files
committed
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
1 parent 7fe7fdd commit ab31281

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/models/attachment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def self.update_attachments(attachments, params)
370370
def self.latest_attach(attachments, filename)
371371
return unless filename.valid_encoding?
372372

373-
attachments.sort_by(&:created_on).reverse.detect do |att|
373+
attachments.sort_by{|attachment| [attachment.created_on, attachment.id]}.reverse.detect do |att|
374374
filename.casecmp?(att.filename)
375375
end
376376
end

0 commit comments

Comments
 (0)