FIX: generate_topic_thumbnails job infinitely running for corrupted images

It's possible that the original topic image is broken in some form, so
we shouldn't try and generate a topic thumbnail for it. The fix will
prevent the generate_topic_thumbnails job being enqueued every time the
topic is viewed.
This commit is contained in:
Blake Erickson
2020-08-13 16:54:28 -06:00
parent d65a839577
commit c2f3c0dc44
3 changed files with 23 additions and 0 deletions

View File

@ -115,6 +115,8 @@ class Topic < ActiveRecord::Base
image_upload &&
SiteSetting.create_thumbnails &&
image_upload.filesize < SiteSetting.max_image_size_kb.kilobytes &&
image_upload.read_attribute(:width) &&
image_upload.read_attribute(:height) &&
enqueue_if_missing &&
Discourse.redis.set(thumbnail_job_redis_key([]), 1, nx: true, ex: 1.minute)
Jobs.enqueue(:generate_topic_thumbnails, { topic_id: id })