From 5f1b7f48f746508c6e734b093808403b310c3947 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 26 Mar 2017 18:03:48 -0500 Subject: [PATCH] Fix exception when autotagging animated_gifs. Fixes this exception caused by the animated_gif autotagger trying to access the image file, which fails if the image is not hosted on the webserver. Magick::ImageMagickError exception raised unable to open image `/var/www/danbooru2/releases/20170322212609/public/data/f0e32c0e2d906c4932858866346f98b5.gif': No such file or directory @ error/blob.c/OpenBlob/2712 app/models/post.rb:177:in `ping' app/models/post.rb:177:in `is_animated_gif?' app/models/post.rb:684:in `add_automatic_tags' app/models/post.rb:638:in `normalize_tags' app/controllers/posts_controller.rb:49:in `update' --- app/models/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index d8053308a..db7d27ba3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -173,7 +173,7 @@ class Post < ActiveRecord::Base end def is_animated_gif? - if file_ext =~ /gif/i + if file_ext =~ /gif/i && File.exists?(file_path) return Magick::Image.ping(file_path).length > 1 else return false