1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

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
This commit is contained in:
Go MAEDA 2021-04-07 05:30:01 +00:00
parent 7fe7fdd7bc
commit ab3128106e

View File

@ -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