git-svn-id: http://svn.redmine.org/redmine/trunk@16460 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/3.4.0
@@ -413,7 +413,9 @@ class Attachment < ActiveRecord::Base | |||
private | |||
def reuse_existing_file_if_possible | |||
with_lock do | |||
original_diskfile = nil | |||
reused = with_lock do | |||
if existing = Attachment | |||
.lock | |||
.where(digest: self.digest, filesize: self.filesize) | |||
@@ -430,10 +432,12 @@ class Attachment < ActiveRecord::Base | |||
self.update_columns disk_directory: existing.disk_directory, | |||
disk_filename: existing.disk_filename | |||
File.delete(original_diskfile) | |||
end | |||
end | |||
end | |||
if reused | |||
File.delete(original_diskfile) | |||
end | |||
end | |||