2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-10 12:04:21 +08:00

FIX: Avoid infinite loop if disk space is low

We now continue to enqueue the pull_hotlinked_images job for optimized images, even if disk space is low
This commit is contained in:
David Taylor 2019-06-07 14:09:02 +01:00
parent fca90106b9
commit e3a9a2d2dd
2 changed files with 10 additions and 6 deletions

View file

@ -1094,10 +1094,10 @@ describe CookedPostProcessor do
SiteSetting.download_remote_images_to_local = true
end
it "does not run when there is not enough disk space" do
cpp.expects(:disable_if_low_on_disk_space).returns(true)
Jobs.expects(:cancel_scheduled_job).never
it "disables download_remote_images if there is not enough disk space" do
cpp.expects(:available_disk_space).returns(5)
cpp.pull_hotlinked_images
expect(SiteSetting.download_remote_images_to_local).to eq(false)
end
context "and there is enough disk space" do
@ -1136,11 +1136,14 @@ describe CookedPostProcessor do
let(:post) { build(:post, created_at: 20.days.ago) }
let(:cpp) { CookedPostProcessor.new(post) }
before { cpp.expects(:available_disk_space).returns(50) }
before do
SiteSetting.download_remote_images_to_local = true
cpp.expects(:available_disk_space).returns(50)
end
it "does nothing when there's enough disk space" do
SiteSetting.expects(:download_remote_images_threshold).returns(20)
SiteSetting.expects(:download_remote_images_to_local).never
SiteSetting.expects(:download_remote_images_to_local=).never
expect(cpp.disable_if_low_on_disk_space).to eq(false)
end