Commit 290d914f by Lance Ivy Committed by Prem Sichanugrist

calculate fingerprints efficiently on large files using Digest::MD5.file()

The tests would broken for StringIO, because it doesn't have a real "path". I've modify the patch to make the test stop complaining [@sikachu]

This closes #470
parent 2df79dd3
......@@ -225,9 +225,13 @@ module Paperclip
end
def generate_fingerprint(source)
data = source.read
source.rewind if source.respond_to?(:rewind)
Digest::MD5.hexdigest(data)
if source.respond_to?(:path) && source.path && !source.path.blank?
Digest::MD5.file(source.path).to_s
else
data = source.read
source.rewind if source.respond_to?(:rewind)
Digest::MD5.hexdigest(data)
end
end
# Paths and URLs can have a number of variables interpolated into them
......
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