From 82c4a8d4b433adcfada2c4aac5789eebb7d36f8d Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 31 Jul 2012 12:05:49 -0400 Subject: [PATCH] on creating outfit image, skip broken images instead of throwing exception --- app/models/outfit.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/outfit.rb b/app/models/outfit.rb index f26a034d..b0d9540a 100644 --- a/app/models/outfit.rb +++ b/app/models/outfit.rb @@ -140,10 +140,16 @@ class Outfit < ActiveRecord::Base unless image_layers.empty? temp_image_files = Parallel.map(image_layers, :in_threads => 8) do |swf_asset| image_file = Tempfile.open(['outfit_layer', '.png']) - write_temp_swf_asset_image!(swf_asset, image_file) - image_file.close - image_file - end + begin + write_temp_swf_asset_image!(swf_asset, image_file) + rescue RightAws::AwsError + nil # skip broken images + else + image_file + ensure + image_file.close + end + end.compact # remove nils for broken images # Here we do some awkwardness to get the exact ImageMagick command we # want, though it's still less awkward than handling the command