Skip to content

Commit

Permalink
Preserve files when reprocessing
Browse files Browse the repository at this point in the history
When using S3 for storage, their data consistency model makes the
current behaviour of Attachment#reprocess! unreliable.

Apparently, Amazon can not guarantee that PUT's called after DELETE's
is actually executed in that order.

Hence, I propose preserving files, when doing a reprocces.
  • Loading branch information
anderslemke authored and Jon Yurek committed Jan 2, 2014
1 parent 0ac38e9 commit 5a06d85
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def hash_key(style_name = default_style)
# the post-process again.
def reprocess!(*style_args)
saved_only_process, @options[:only_process] = @options[:only_process], style_args
saved_preserve_files, @options[:preserve_files] = @options[:preserve_files], true
begin
assign(self)
save
Expand All @@ -323,6 +324,7 @@ def reprocess!(*style_args)
false
ensure
@options[:only_process] = saved_only_process
@options[:preserve_files] = saved_preserve_files
end
end

Expand Down

0 comments on commit 5a06d85

Please sign in to comment.