A platform for community discussion. Free, open, simple.
FIX: Avoid pulling hotlinked images of post that have been deleted. (#11913)
Alan Guo Xiang Tan0cc178d58bbf
diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rbindex 5a6ab648a59..83c9705d839 100644--- a/app/jobs/regular/pull_hotlinked_images.rb+++ b/app/jobs/regular/pull_hotlinked_images.rb@@ -15,6 +15,7 @@ module Jobspost = Post.find_by(id: @post_id)return if post.blank?+ return if post.topic.blank?raw = post.raw.dupstart_raw = raw.dupdiff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rbindex adb7a56d7eb..64ed3f3b7b1 100644--- a/spec/jobs/pull_hotlinked_images_spec.rb+++ b/spec/jobs/pull_hotlinked_images_spec.rb@@ -42,6 +42,15 @@ describe Jobs::PullHotlinkedImages doJobs.run_immediately!end+ it 'does nothing if topic has been deleted' do+ post = Fabricate(:post, raw: "<img src='#{image_url}'>")+ post.topic.destroy!++ expect do+ Jobs::PullHotlinkedImages.new.execute(post_id: post.id)+ end.to change { Upload.count }.by(0)+ end+it 'does nothing if there are no large images to pull' dopost = Fabricate(:post, raw: 'bob bob')orig = post.updated_at