diff options
author | George Claghorn <george@basecamp.com> | 2017-12-18 22:01:48 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2017-12-18 22:01:48 -0500 |
commit | 2df99f8bc57a39e1565fb6ffeedb87c594334c8b (patch) | |
tree | 6492d5067f5e707d898e2fde2f2df15872c8eece /activestorage | |
parent | d9e4bffb60f69d972311fa7d23f4ce540adc54a9 (diff) | |
download | rails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.tar.gz rails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.tar.bz2 rails-2df99f8bc57a39e1565fb6ffeedb87c594334c8b.zip |
Delete MiniMagick tempfile when transformation fails
Diffstat (limited to 'activestorage')
-rw-r--r-- | activestorage/app/models/active_storage/variant.rb | 8 |
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 |