Commit 70bcb871 authored by jplang's avatar jplang

Adds file equality check to deduplication hook (#25215).

Patch by Jens Kraemer.

git-svn-id: https://svn.redmine.org/redmine/trunk@16459 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 4d52bd06
......@@ -422,9 +422,16 @@ class Attachment < ActiveRecord::Base
.first
original_diskfile = self.diskfile
self.update_columns disk_directory: existing.disk_directory,
disk_filename: existing.disk_filename
File.delete(original_diskfile) if File.exist?(original_diskfile)
existing_diskfile = existing.diskfile
if File.readable?(original_diskfile) &&
File.readable?(existing_diskfile) &&
FileUtils.identical?(original_diskfile, existing_diskfile)
self.update_columns disk_directory: existing.disk_directory,
disk_filename: existing.disk_filename
File.delete(original_diskfile)
end
end
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