summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/attachment.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index f838076c6..3bcc266bc 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -72,7 +72,7 @@ class Attachment < ActiveRecord::Base
File.open(diskfile, "wb") do |f|
f.write(@temp_file.read)
end
- self.digest = Digest::MD5.hexdigest(File.read(diskfile))
+ self.digest = self.class.digest(diskfile)
end
# Don't save the content type if it's longer than the authorized length
if self.content_type && self.content_type.length > 255
@@ -133,4 +133,11 @@ private
end
df
end
+
+ # Returns the MD5 digest of the file at given path
+ def self.digest(filename)
+ File.open(filename, 'rb') do |f|
+ Digest::MD5.hexdigest(f.read)
+ end
+ end
end