summaryrefslogtreecommitdiffstats
path: root/app/models/attachment.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-09-28 14:25:35 +0000
committerGo MAEDA <maeda@farend.jp>2020-09-28 14:25:35 +0000
commit26bc3838e14dc946e27b2bc653ae61263e7ff1c4 (patch)
tree8a6b3508e441fdf5d3d1e6147260a6c4df898119 /app/models/attachment.rb
parent82e0fe13a312a0292ad7faeddd3315704619ae6d (diff)
downloadredmine-26bc3838e14dc946e27b2bc653ae61263e7ff1c4.tar.gz
redmine-26bc3838e14dc946e27b2bc653ae61263e7ff1c4.zip
When creating more than two identical attachments in a single transaction, the first one always ends up unreadable (#33769).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@20094 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/attachment.rb')
-rw-r--r--app/models/attachment.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index b0cc94cb2..112232c64 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -470,7 +470,8 @@ class Attachment < ActiveRecord::Base
.where(digest: self.digest, filesize: self.filesize)
.where('id <> ? and disk_filename <> ?',
self.id, self.disk_filename)
- .first
+ .order(:id)
+ .last
existing.with_lock do
original_diskfile = self.diskfile
existing_diskfile = existing.diskfile