aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2017-12-18 22:01:48 -0500
committerGeorge Claghorn <george@basecamp.com>2017-12-18 22:01:48 -0500
commit2df99f8bc57a39e1565fb6ffeedb87c594334c8b (patch)
tree6492d5067f5e707d898e2fde2f2df15872c8eece /activestorage/app
parentd9e4bffb60f69d972311fa7d23f4ce540adc54a9 (diff)
downloadrails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.tar.gz
rails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.tar.bz2
rails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.zip
Delete MiniMagick tempfile when transformation fails
Diffstat (limited to 'activestorage/app')
-rw-r--r--activestorage/app/models/active_storage/variant.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activestorage/app/models/active_storage/variant.rb b/activestorage/app/models/active_storage/variant.rb
index ece99518be..bdcb5e6a41 100644
--- a/activestorage/app/models/active_storage/variant.rb
+++ b/activestorage/app/models/active_storage/variant.rb
@@ -104,7 +104,13 @@ class ActiveStorage::Variant
def open_image(&block)
- download_image.tap(&block).destroy!
+ image = download_image
+
+ begin
+ yield image
+ ensure
+ image.destroy!
+ end
end
def download_image