summaryrefslogtreecommitdiffstats
path: root/app/models/attachment.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-02 17:57:13 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-02 17:57:13 +0000
commit93c04f2666b60af890a7431bec802b7d00e29b34 (patch)
treee7ef2e994863caaa9d6b89cc42c638f24c412a17 /app/models/attachment.rb
parent218e1bb267d6c28edc063a9b617258ee5f1051cf (diff)
downloadredmine-93c04f2666b60af890a7431bec802b7d00e29b34.tar.gz
redmine-93c04f2666b60af890a7431bec802b7d00e29b34.zip
Fixed: wrong digest for text files under Windows (#2264).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2085 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/attachment.rb')
-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