FIX: In FastImage 2.2.2 an error is raised with a `nil` path (#11954)

* 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>
This commit is contained in:
Robin Ward 2021-02-03 11:45:12 -05:00 committed by GitHub
parent 155ae06f62
commit 93c25070fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -6,7 +6,7 @@ module Jobs
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))
extension = FastImage.type(Discourse.store.path_for(upload)) rescue nil
current_extension = upload.extension
if extension.to_s.downcase != current_extension.to_s.downcase