]> cat aescling's git repositories - mastodon.git/commitdiff
Try to avoid any potential loops
authorEugen <eugen@zeonfederated.com>
Thu, 19 Jan 2017 01:14:57 +0000 (02:14 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Jan 2017 01:14:57 +0000 (02:14 +0100)
app/models/account.rb

index 5d6324a7b55262b41cd4071f1fcc8ad2e1d10562..621a66e24b8cb5ee59616575384d5df133347af3 100644 (file)
@@ -125,13 +125,9 @@ class Account < ApplicationRecord
 
   def save_with_optional_avatar!
     save!
-  rescue ActiveRecord::RecordInvalid => invalid
-    if invalid.record.errors[:avatar_file_size] || invalid.record.errors[:avatar_content_type]
-      self.avatar = nil
-      retry
-    end
-
-    raise invalid
+  rescue ActiveRecord::RecordInvalid
+    self.avatar = nil
+    save!
   end
 
   def avatar_remote_url=(url)