Skip to content

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

FIX: Wrong order for `S3Helper#copy_file`.

Guo Xiang Tan1ea23b1eaea8
diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb
index 61d58559544..cf814912922 100644
--- a/lib/s3_helper.rb
+++ b/lib/s3_helper.rb
@@ -33,8 +33,8 @@ class S3Helper
# copy the file in tombstone
if copy_to_tombstone && @tombstone_prefix.present?
self.copy(
- File.join(@tombstone_prefix, s3_filename),
- get_path_for_s3_upload(s3_filename)
+ get_path_for_s3_upload(s3_filename),
+ File.join(@tombstone_prefix, s3_filename)
)
end
@@ -45,8 +45,8 @@ class S3Helper
def copy(source, destination)
s3_bucket
- .object(source)
- .copy_from(copy_source: File.join(@s3_bucket_name, destination))
+ .object(destination)
+ .copy_from(copy_source: File.join(@s3_bucket_name, source))
end
# make sure we have a cors config for assets
diff --git a/spec/components/file_store/s3_store_spec.rb b/spec/components/file_store/s3_store_spec.rb
index 58cecf5e00c..06948702dd7 100644
--- a/spec/components/file_store/s3_store_spec.rb
+++ b/spec/components/file_store/s3_store_spec.rb
@@ -125,10 +125,10 @@ describe FileStore::S3Store do
s3_object = stub
- s3_bucket.expects(:object).with(source).returns(s3_object)
+ s3_bucket.expects(:object).with(destination).returns(s3_object)
s3_object.expects(:copy_from).with(
- copy_source: "s3-upload-bucket/#{destination}"
+ copy_source: "s3-upload-bucket/#{source}"
)
store.copy_file(upload.url, source, destination)