Skip to content

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

FIX: Set `tagging_directive` to "REPLACE" in `S3Helper#copy` (#37710)

Alan Guo Xiang Tan92b6c95f3962
diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb
index 623c30d957a..2bf36fe3384 100644
--- a/lib/s3_helper.rb
+++ b/lib/s3_helper.rb
@@ -118,6 +118,8 @@ class S3Helper
options = options.except(:apply_metadata_to_destination).merge(metadata_directive: "REPLACE")
end
+ options[:tagging_directive] = "REPLACE" if options[:tagging]
+
destination = get_path_for_s3_upload(destination)
source_object =
if !Rails.configuration.multisite || source.include?(multisite_upload_path) ||
diff --git a/spec/lib/file_store/s3_store_spec.rb b/spec/lib/file_store/s3_store_spec.rb
index eff8d8d099a..de3193de000 100644
--- a/spec/lib/file_store/s3_store_spec.rb
+++ b/spec/lib/file_store/s3_store_spec.rb
@@ -518,6 +518,8 @@ RSpec.describe FileStore::S3Store do
FileStore::S3Store.visibility_tagging_option_value(secure: false),
)
+ expect(copy_api_request[:context].params[:tagging_directive]).to eq("REPLACE")
+
expect(bucket.find_object(source)).to be_present
expect(bucket.find_object(destination)).to be_present
end
@@ -552,6 +554,8 @@ RSpec.describe FileStore::S3Store do
FileStore::S3Store.visibility_tagging_option_value(secure: true),
)
+ expect(copy_api_request[:context].params[:tagging_directive]).to eq("REPLACE")
+
expect(bucket.find_object(source)).to be_present
expect(bucket.find_object(destination)).to be_present
end