FIX: Always schedule pull_hotlinked_images in cooked_post_processor

FIX: Always schedule pull_hotlinked_images in cooked_post_processor

The job is now used to pull optimized images, and images from other sites on the same CDN. This needs to run even if download_remote_images is false

diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb
index a8d38ea..92d48bd 100644
--- a/lib/cooked_post_processor.rb
+++ b/lib/cooked_post_processor.rb
@@ -626,8 +626,6 @@ class CookedPostProcessor
   end
 
   def pull_hotlinked_images(bypass_bump = false)
-    # is the job enabled?
-    return unless SiteSetting.download_remote_images_to_local?
     # have we enough disk space?
     return if disable_if_low_on_disk_space
     # don't download remote images for posts that are more than n days old
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index 0df302a..43203da 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -1082,10 +1082,11 @@ describe CookedPostProcessor do
 
     before { cpp.stubs(:available_disk_space).returns(90) }
 
-    it "does not run when download_remote_images_to_local is disabled" do
+    it "runs even when download_remote_images_to_local is disabled" do
+      # We want to run it to pull hotlinked optimized images
       SiteSetting.download_remote_images_to_local = false
-      Jobs.expects(:cancel_scheduled_job).never
-      cpp.pull_hotlinked_images
+      expect { cpp.pull_hotlinked_images }.
+        to change { Jobs::PullHotlinkedImages.jobs.count }.by 1
     end
 
     context "when download_remote_images_to_local? is enabled" do

GitHub sha: 65b0cafc

1 Like