mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't raise an error when the upload can't be retrieved
This commit is contained in:
parent
e8c89b4535
commit
87ac758f05
@ -21,12 +21,14 @@ class UserAvatar < ActiveRecord::Base
|
|||||||
max = Discourse.avatar_sizes.max
|
max = Discourse.avatar_sizes.max
|
||||||
gravatar_url = "http://www.gravatar.com/avatar/#{email_hash}.png?s=#{max}&d=404"
|
gravatar_url = "http://www.gravatar.com/avatar/#{email_hash}.png?s=#{max}&d=404"
|
||||||
tempfile = FileHelper.download(gravatar_url, SiteSetting.max_image_size_kb.kilobytes, "gravatar")
|
tempfile = FileHelper.download(gravatar_url, SiteSetting.max_image_size_kb.kilobytes, "gravatar")
|
||||||
upload = UploadCreator.new(tempfile, 'gravatar.png', origin: gravatar_url, type: "avatar").create_for(user_id)
|
if tempfile
|
||||||
|
upload = UploadCreator.new(tempfile, 'gravatar.png', origin: gravatar_url, type: "avatar").create_for(user_id)
|
||||||
|
|
||||||
if gravatar_upload_id != upload.id
|
if gravatar_upload_id != upload.id
|
||||||
gravatar_upload.try(:destroy!) rescue nil
|
gravatar_upload.try(:destroy!) rescue nil
|
||||||
self.gravatar_upload = upload
|
self.gravatar_upload = upload
|
||||||
save!
|
save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
save!
|
save!
|
||||||
|
Loading…
Reference in New Issue
Block a user