mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Prevent thumbnail gen if image too large (#10247)
It's possible through an import or other means to have images larger than the current max allowed image size in the db. If this happens the thumbnail generation job will keep running indefinitely trying to download a new copy of the original but discarding it because it is larger than the max_file_size eventually causing this error `Job exception: undefined method `path' for nil:NilClass` because the newly downloaded image is now nil. This fix stops the enqueuing of the `GenerateTopicThumbnails` job for all images that happen to be larger than the max image size.
This commit is contained in:
@@ -5,6 +5,9 @@ describe "TopicThumbnail" do
|
||||
let(:upload1) { Fabricate(:image_upload, width: 5000, height: 5000) }
|
||||
let(:topic) { Fabricate(:topic, image_upload: upload1) }
|
||||
|
||||
let(:upload2) { Fabricate(:image_upload, width: 5000, height: 5000, filesize: 8000) }
|
||||
let(:topic2) { Fabricate(:topic, image_upload: upload2) }
|
||||
|
||||
before do
|
||||
SiteSetting.create_thumbnails = true
|
||||
topic.generate_thumbnails!(extra_sizes: nil)
|
||||
@@ -15,6 +18,16 @@ describe "TopicThumbnail" do
|
||||
expect(topic.topic_thumbnails.length).to eq(1)
|
||||
end
|
||||
|
||||
it "does not enque job if original image is too large" do
|
||||
SiteSetting.create_thumbnails = true
|
||||
topic2.generate_thumbnails!(extra_sizes: nil)
|
||||
|
||||
TopicThumbnail.ensure_consistency!
|
||||
topic2.reload
|
||||
|
||||
expect(topic2.topic_thumbnails.length).to eq(0)
|
||||
end
|
||||
|
||||
it "cleans up deleted uploads" do
|
||||
upload1.delete
|
||||
|
||||
|
||||
Reference in New Issue
Block a user