Ensure result file is deleted on uploading errors

This commit is contained in:
Janko Marohnić 2018-04-22 23:43:11 +02:00
parent f01e249890
commit 0d811fd482
No known key found for this signature in database
GPG Key ID: 84166B4FB1C84F3E

@ -100,9 +100,9 @@ def processed?
def process
download_blob_to_tempfile do |image|
variant = transform image
upload variant
variant.close!
transform image do |output|
upload output
end
end
end
@ -121,7 +121,13 @@ def content_type
def transform(image)
format = "png" unless WEB_IMAGE_CONTENT_TYPES.include?(blob.content_type)
variation.transform(image, format: format)
result = variation.transform(image, format: format)
begin
yield result
ensure
result.close!
end
end
def upload(file)