Commit e321608f by Dan Collis-Puro Committed by Jon Yurek

Revert Paperclip::Storage::Filesystem#flush_writes

This commit makes this method move by default instead of copying, which
should make it perform significantly better with large files. It falls
back to the old semantics if the mv fails.
parent 6a388c73
...@@ -36,9 +36,13 @@ module Paperclip ...@@ -36,9 +36,13 @@ module Paperclip
def flush_writes #:nodoc: def flush_writes #:nodoc:
@queued_for_write.each do |style_name, file| @queued_for_write.each do |style_name, file|
FileUtils.mkdir_p(File.dirname(path(style_name))) FileUtils.mkdir_p(File.dirname(path(style_name)))
File.open(path(style_name), "wb") do |new_file| begin
while chunk = file.read(16 * 1024) FileUtils.mv(file.path, path(style_name))
new_file.write(chunk) rescue SystemCallError
File.open(path(style_name), "wb") do |new_file|
while chunk = file.read(16 * 1024)
new_file.write(chunk)
end
end end
end end
unless @options[:override_file_permissions] == false unless @options[:override_file_permissions] == 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