mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
DEV: Allow site administrators to mark S3 uploads with a missing status (#27222)
This commit introduces the following changes which allows a site administrator to mark `Upload` records with the `s3_file_missing` verification status which will result in the `Upload` record being ignored when `Discourse.store.list_missing_uploads` is ran on a site where S3 uploads are enabled and `SiteSetting.enable_s3_inventory` is set to `true`. 1. Introduce `s3_file_missing` to `Upload.verification_statuses` 2. Introduce `Upload.mark_invalid_s3_uploads_as_missing` which updates `Upload#verification_status` of all `Upload` records from `invalid_etag` to `s3_file_missing`. 3. Introduce `rake uploads:mark_invalid_s3_uploads_as_missing` Rake task which allows a site administrator to change `Upload` records with `invalid_etag` verification status to the `s3_file_missing` verificaton_status. 4. Update `S3Inventory` to ignore `Upload` records with the `s3_file_missing` verification status.
This commit is contained in:

committed by
GitHub

parent
2d1ab4c9e3
commit
dc55b645b2
@ -809,4 +809,28 @@ RSpec.describe Upload do
|
||||
expect { u.update!(dominant_color: "abcd") }.to raise_error(ActiveRecord::RecordInvalid)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".mark_invalid_s3_uploads_as_missing" do
|
||||
it "should update all upload records with a `verification_status` of `invalid_etag` to `s3_file_missing`" do
|
||||
upload_1 =
|
||||
Fabricate(:upload_s3, verification_status: Upload.verification_statuses[:invalid_etag])
|
||||
|
||||
upload_2 =
|
||||
Fabricate(:upload_s3, verification_status: Upload.verification_statuses[:invalid_etag])
|
||||
|
||||
upload_3 = Fabricate(:upload_s3, verification_status: Upload.verification_statuses[:verified])
|
||||
|
||||
Upload.mark_invalid_s3_uploads_as_missing
|
||||
|
||||
expect(upload_1.reload.verification_status).to eq(
|
||||
Upload.verification_statuses[:s3_file_missing_confirmed],
|
||||
)
|
||||
|
||||
expect(upload_2.reload.verification_status).to eq(
|
||||
Upload.verification_statuses[:s3_file_missing_confirmed],
|
||||
)
|
||||
|
||||
expect(upload_3.reload.verification_status).to eq(Upload.verification_statuses[:verified])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user