From 2df99f8bc57a39e1565fb6ffeedb87c594334c8b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 18 Dec 2017 22:01:48 -0500 Subject: Delete MiniMagick tempfile when transformation fails --- activestorage/app/models/active_storage/variant.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'activestorage/app/models/active_storage/variant.rb') 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 -- cgit v1.2.3