From 76198c63b613f353f2e4a82ce89a8450ca219b88 Mon Sep 17 00:00:00 2001
From: Paul Woolcock <paul@woolcock.us>
Date: Mon, 26 Feb 2018 16:01:49 -0500
Subject: [PATCH] Some images can cause `convert` to fail, which crashes this
 whole task (#6565)

* Some images can cause `convert` to fail, which crashes this whole task

* Add more specific exception
---
 lib/tasks/mastodon.rake | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index bf4c53cb3..a06e35226 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -494,9 +494,13 @@ namespace :mastodon do
       accounts = accounts.where(domain: ENV['DOMAIN']) if ENV['DOMAIN'].present?
 
       accounts.find_each do |account|
-        account.reset_avatar!
-        account.reset_header!
-        account.save
+        begin
+          account.reset_avatar!
+          account.reset_header!
+          account.save
+        rescue Paperclip::Error
+          puts "Error resetting avatar and header for account #{username}@#{domain}"
+        end
       end
     end
   end