about summary refs log tree commit diff
path: root/app/models/concerns/remotable.rb
diff options
context:
space:
mode:
authorTakeshi Umeda <noel.yoshiba@gmail.com>2021-05-11 21:19:22 +0900
committerGitHub <noreply@github.com>2021-05-11 14:19:22 +0200
commitc403c3695b1943882bf88afa9caf55bd8c6acc2f (patch)
tree04a8fbd636212c5cfa849c5a71e1733f298d954b /app/models/concerns/remotable.rb
parentb5ad787ebf33b475379d38211c646845f1dcd934 (diff)
Fix to be able to redownload avatar and header (#16190)
* Fix to reset if header and avatar download fails

* Add RedownloadAvatarWorker and RedownloadHeaderWorker
Diffstat (limited to 'app/models/concerns/remotable.rb')
-rw-r--r--app/models/concerns/remotable.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb
index 56b9c0164..ffe8a7565 100644
--- a/app/models/concerns/remotable.rb
+++ b/app/models/concerns/remotable.rb
@@ -28,9 +28,11 @@ module Remotable
           end
         rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
           Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
+          public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
           raise e unless suppress_errors
         rescue Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError, Paperclip::Error, Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e
           Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}"
+          public_send("#{attachment_name}=", nil) if public_send("#{attachment_name}_file_name").present?
         end
 
         nil