diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb index d4bb6647d29..aa385848997 100644 --- a/lib/file_store/s3_store.rb +++ b/lib/file_store/s3_store.rb @@ -126,8 +126,8 @@ module FileStore def list_missing_uploads(skip_optimized: false) if SiteSetting.enable_s3_inventory require 's3_inventory' - S3Inventory.new(s3_helper, :upload).list_missing - S3Inventory.new(s3_helper, :optimized).list_missing unless skip_optimized + S3Inventory.new(s3_helper, :upload).backfill_etags_and_list_missing + S3Inventory.new(s3_helper, :optimized).backfill_etags_and_list_missing unless skip_optimized else list_missing(Upload, "original/") list_missing(OptimizedImage, "optimized/") unless skip_optimized diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb index 1625e4309eb..01055f1925e 100644 --- a/lib/s3_inventory.rb +++ b/lib/s3_inventory.rb @@ -24,7 +24,7 @@ class S3Inventory end end - def list_missing + def backfill_etags_and_list_missing if files.blank? error("Failed to list inventory from S3") return diff --git a/spec/components/s3_inventory_spec.rb b/spec/components/s3_inventory_spec.rb index 03d70aea070..1a6d9e5ee70 100644 --- a/spec/components/s3_inventory_spec.rb +++ b/spec/components/s3_inventory_spec.rb @@ -51,7 +51,7 @@ describe "S3Inventory" do it "should raise error if an inventory file is not found" do client.stub_responses(:list_objects, contents: []) - output = capture_stdout { inventory.list_missing } + output = capture_stdout { inventory.backfill_etags_and_list_missing } expect(output).to eq("Failed to list inventory from S3\n") end @@ -70,7 +70,7 @@ describe "S3Inventory" do inventory.expects(:inventory_date).returns(Time.now) output = capture_stdout do - inventory.list_missing + inventory.backfill_etags_and_list_missing end expect(output).to eq("#{upload.url}\n1 of 4 uploads are missing\n") @@ -88,7 +88,7 @@ describe "S3Inventory" do inventory.expects(:files).returns([{ key: "Key", filename: "#{csv_filename}.gz" }]).times(2) output = capture_stdout do - expect { inventory.list_missing }.to change { Upload.where(etag: nil).count }.by(-2) + expect { inventory.backfill_etags_and_list_missing }.to change { Upload.where(etag: nil).count }.by(-2) end expect(Upload.order(:url).pluck(:url, :etag)).to eq(files)