1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-01 05:09:40 +00:00

Delete the file after the change is committed (#25215).

git-svn-id: http://svn.redmine.org/redmine/trunk@16460 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2017-04-03 12:13:07 +00:00
parent 2f83c57be4
commit 0e407dcf46

View File

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