mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 03:53:51 +08:00
93c25070fa
* FIX: In FastImage 2.2.2 an error is raised with a `nil` path Sometimes Discourse.store.path_for would return `nil`, which the job handled gracefully before, but raises an error with the new version of the gem. Note the logic of this job is a bit awkward since it depends on `nil` being a string, but at least now it's no longer filling logs with errors. * Update app/jobs/onceoff/fix_invalid_gravatar_uploads.rb Co-authored-by: Bianca Nenciu <nbianca@users.noreply.github.com> Co-authored-by: Bianca Nenciu <nbianca@users.noreply.github.com>
19 lines
633 B
Ruby
19 lines
633 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class FixInvalidGravatarUploads < ::Jobs::Onceoff
|
|
def execute_onceoff(args)
|
|
Upload.where(original_filename: "gravatar.png").find_each do |upload|
|
|
# note, this still feels pretty expensive for a once off
|
|
# we may need to re-evaluate this
|
|
extension = FastImage.type(Discourse.store.path_for(upload)) rescue nil
|
|
current_extension = upload.extension
|
|
|
|
if extension.to_s.downcase != current_extension.to_s.downcase
|
|
upload&.user&.user_avatar&.update_columns(last_gravatar_download_attempt: nil)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|