Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaning up the downloaded original file if it is a tempfile, such as…

… it is with s3 storage.
  • Loading branch information...
commit 748332eb5d8d3003477de7b1089e7248e0f46040 1 parent e526c86
@danielevans danielevans authored sikachu committed
Showing with 17 additions and 0 deletions.
  1. +1 −0  lib/paperclip/attachment.rb
  2. +16 −0 test/integration_test.rb
View
1  lib/paperclip/attachment.rb
@@ -291,6 +291,7 @@ def reprocess!(*style_args)
post_process(*style_args)
old_original.close if old_original.respond_to?(:close)
+ old_original.unlink if old_original.respond_to?(:unlink)
save
else
View
16 test/integration_test.rb
@@ -71,6 +71,22 @@ class IntegrationTest < Test::Unit::TestCase
should "change the timestamp" do
assert_not_equal @original_timestamp, @d2.avatar_updated_at
end
+
+ should "clean up the old original if it is a tempfile" do
+ original = @d2.avatar.to_file(:original)
+ tf = Paperclip::Tempfile.new('original')
+ tf.binmode
+ original.binmode
+ tf.write(original.read)
+ original.close
+ tf.rewind
+
+ File.expects(:unlink).with(tf.instance_variable_get(:@tmpname))
+
+ @d2.avatar.expects(:to_file).with(:original).returns(tf)
+
+ @d2.avatar.reprocess!
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.