FIX: destroy optimized images that cant' be migrated to new scheme

Since we can always recompute an optimized image from the original upload, there's no need to keep optimized images that are generating errors.
This commit is contained in:
Régis Hanol 2015-06-15 18:30:11 +02:00
parent fb8ba5e137
commit 87ab1cef8e

View File

@ -220,6 +220,8 @@ class OptimizedImage < ActiveRecord::Base
end
rescue => e
problems << { optimized_image: optimized_image, ex: e }
# just ditch the optimized image if there was any errors
optimized_image.destroy
ensure
file.try(:unlink) rescue nil
file.try(:close) rescue nil