Browse Source

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

git-svn-id: http://svn.redmine.org/redmine/trunk@16460 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 7 years ago
parent
commit
0e407dcf46
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      app/models/attachment.rb

+ 6
- 2
app/models/attachment.rb 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



Loading…
Cancel
Save