From 652abaf8284ed3fa0453eff80f8209834f8a4493 Mon Sep 17 00:00:00 2001 From: Cezar Halmagean Date: Tue, 21 Nov 2017 14:32:15 +0200 Subject: [PATCH] Check if file exists on disk before calling identify If the file is not on disk, identify can't be called so we need to check for a file first. Calling `image_file.file` will throw an exception if the file doesn't exist so it will be catched by the rescue. --- lib/alchemy/upgrader/three_point_four.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/alchemy/upgrader/three_point_four.rb b/lib/alchemy/upgrader/three_point_four.rb index 3f60ce2426..e1f11495c2 100644 --- a/lib/alchemy/upgrader/three_point_four.rb +++ b/lib/alchemy/upgrader/three_point_four.rb @@ -18,7 +18,7 @@ def store_image_file_format pictures.find_each(batch_size: 100).with_index do |pic, i| begin puts " -> Reading file format of #{pic.image_file_name} (#{i + 1}/#{count})" - format = pic.image_file.identify('-ping -format "%m"') + format = pic.image_file.identify('-ping -format "%m"') if pic.image_file.file pic.update_column('image_file_format', format.to_s.chomp.downcase) converted_pics += 1 rescue Dragonfly::Job::Fetch::NotFound => e