Permalink
Browse files

Falling back from mv to cp/rm on error.

Closes #388
  • Loading branch information...
1 parent 290d914 commit 1ff1cc731a661addcd3c33d324c1fcb78c546607 @ryansch ryansch committed with sikachu Jun 28, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/paperclip/storage/filesystem.rb
View
7 lib/paperclip/storage/filesystem.rb
@@ -38,7 +38,12 @@ def flush_writes #:nodoc:
file.close
FileUtils.mkdir_p(File.dirname(path(style_name)))
log("saving #{path(style_name)}")
- FileUtils.mv(file.path, path(style_name))
+ begin
+ FileUtils.mv(file.path, path(style_name))
+ rescue SystemCallError
+ FileUtils.cp(file.path, path(style_name))
+ FileUtils.rm(file.path)
+ end
FileUtils.chmod(0644, path(style_name))
end
@queued_for_write = {}

0 comments on commit 1ff1cc7

Please sign in to comment.