Commit a9e09d1b by Pavel Pravosud Committed by Jon Yurek

Don't forget to close local file handler if something goes wrong

parent c1c20f30
......@@ -145,10 +145,10 @@ module Paperclip
def copy_to_local_file(style, local_dest_path)
log("copying #{path(style)} to local file #{local_dest_path}")
local_file = ::File.open(local_dest_path, 'wb')
file = directory.files.get(path(style))
local_file.write(file.body)
local_file.close
::File.open(local_dest_path, 'wb') do |local_file|
file = directory.files.get(path(style))
local_file.write(file.body)
end
rescue ::Fog::Errors::Error => e
warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
false
......
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