Skip to content

A platform for community discussion. Free, open, simple.

DEV: skip S3 inventory records without correct multisite prefix.

Vinoth Kannand74ee9dbce7f
diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb
index 83b64b25a8c..19901765a22 100644
--- a/lib/s3_inventory.rb
+++ b/lib/s3_inventory.rb
@@ -34,13 +34,16 @@ class S3Inventory
download_inventory_files_to_tmp_directory
decompress_inventory_files
+ multisite_prefix = "uploads/#{RailsMultisite::ConnectionManagement.current_db}/"
ActiveRecord::Base.transaction do
begin
connection.exec("CREATE TEMP TABLE #{table_name}(key text UNIQUE, etag text, PRIMARY KEY(etag, key))")
connection.copy_data("COPY #{table_name} FROM STDIN CSV") do
files.each do |file|
CSV.foreach(file[:filename][0...-3], headers: false) do |row|
- connection.put_copy_data("#{row[CSV_KEY_INDEX]},#{row[CSV_ETAG_INDEX]}\n")
+ key = row[CSV_KEY_INDEX]
+ next if Rails.configuration.multisite && key.exclude?(multisite_prefix)
+ connection.put_copy_data("#{key},#{row[CSV_ETAG_INDEX]}\n")
end
end
end