FIX: skip uploads without etag in s3 inventory check.

This commit is contained in:
Vinoth Kannan 2019-05-20 00:09:52 +05:30
parent f2326ce83f
commit 2a7065c505
3 changed files with 6 additions and 3 deletions

View File

@ -533,4 +533,4 @@ DEPENDENCIES
webpush
BUNDLED WITH
1.17.3
2.0.1

View File

@ -55,7 +55,9 @@ class S3Inventory
list_missing_post_uploads if type == "original"
uploads = (model == Upload) ? model.by_users.where("created_at < ?", inventory_date) : model
missing_uploads = uploads.joins("LEFT JOIN #{table_name} ON #{table_name}.etag = #{model.table_name}.etag").where("#{table_name}.etag is NULL")
missing_uploads = uploads
.joins("LEFT JOIN #{table_name} ON #{table_name}.etag = #{model.table_name}.etag")
.where("#{table_name}.etag IS NULL AND #{model.table_name}.etag IS NOT NULL")
if (missing_count = missing_uploads.count) > 0
missing_uploads.select(:id, :url).find_each do |upload|

View File

@ -65,6 +65,7 @@ describe "S3Inventory" do
upload = Fabricate(:upload, etag: "ETag", created_at: 1.days.ago)
Fabricate(:upload, etag: "ETag2", created_at: Time.now)
Fabricate(:upload, created_at: 2.days.ago)
inventory.expects(:download_inventory_files_to_tmp_directory)
inventory.expects(:decompress_inventory_files)
@ -75,7 +76,7 @@ describe "S3Inventory" do
inventory.backfill_etags_and_list_missing
end
expect(output).to eq("Listing missing post uploads...\n0 post uploads are missing.\n#{upload.url}\n1 of 4 uploads are missing\n")
expect(output).to eq("Listing missing post uploads...\n0 post uploads are missing.\n#{upload.url}\n1 of 5 uploads are missing\n")
expect(Discourse.stats.get("missing_s3_uploads")).to eq(1)
end