Commit 9d3b923b authored by jplang's avatar jplang

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

git-svn-id: https://svn.redmine.org/redmine/trunk@16460 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 70bcb871
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment