Skip to content

Commit

Permalink
Added reprocess! method. The rake task will actually reprocess the da…
Browse files Browse the repository at this point in the history
…ta it has now instead of ignoring it.
  • Loading branch information
Jon Yurek committed May 13, 2008
1 parent 7832694 commit 4e9acd6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ def self.interpolations
}
end

# This method really shouldn't be called that often. It's expected use is in the
# paperclip:refresh rake task and that's it. It will regenerate all thumbnails
# forcefully, by reobtaining the original file and going through the post-process
# again.
def reprocess!
new_original = Tempfile.new("paperclip-reprocess")
old_original = to_file(:original)
new_original.write( old_original.read )
new_original.rewind

@queued_for_write = { :original => new_original }
post_process

old_original.close if old_original.respond_to?(:close)
end

private

def valid_assignment? file #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion tasks/paperclip_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace :paperclip do
instances.each do |instance|
names.each do |name|
result = if instance.send("#{ name }?")
instance.send(name).send("post_process")
instance.send(name).reprocess!
instance.send(name).save
else
true
Expand Down

0 comments on commit 4e9acd6

Please sign in to comment.