Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Onceoff job to recover missing post uploads.
This fixes the regression due to 1f636c4
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require_dependency "upload_recovery" | ||
|
||
module Jobs | ||
class RecoverPostUploads < Jobs::Onceoff | ||
MIN_PERIOD = 30 | ||
MAX_PERIOD = 120 | ||
|
||
def execute_onceoff(args) | ||
UploadRecovery.new.recover(Post.where( | ||
"baked_at >= ?", | ||
grace_period.days.ago | ||
)) | ||
end | ||
|
||
def grace_period | ||
SiteSetting.purge_deleted_uploads_grace_period_days.clamp( | ||
MIN_PERIOD, | ||
MAX_PERIOD | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Jobs::RecoverPostUploads do | ||
describe '#grace_period' do | ||
it 'should restrict the grace period to the right range' do | ||
SiteSetting.purge_deleted_uploads_grace_period_days = | ||
described_class::MIN_PERIOD - 1 | ||
|
||
expect(described_class.new.grace_period).to eq(30) | ||
|
||
SiteSetting.purge_deleted_uploads_grace_period_days = | ||
described_class::MAX_PERIOD + 1 | ||
|
||
expect(described_class.new.grace_period).to eq(120) | ||
end | ||
end | ||
end |
8a17138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/half-the-images-of-a-thread-have-disappeared-even-though-they-are-still-accessible-in-the-uploads-file-on-the-vps/97136/3