mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: Support subfolders in S3 bucket name.
This commit also fixes a bug where s3 uploads are not moved to a tombstone folder when removed.
This commit is contained in:
@ -16,18 +16,18 @@ class S3Helper
|
||||
obj.upload_file(file, options)
|
||||
end
|
||||
|
||||
def remove(path, copy_to_tombstone=false)
|
||||
def remove(s3_filename, tombstone_filename=false)
|
||||
bucket = s3_bucket
|
||||
|
||||
# copy the file in tombstone
|
||||
if copy_to_tombstone && @tombstone_prefix.present?
|
||||
if tombstone_filename && @tombstone_prefix.present?
|
||||
bucket
|
||||
.object(File.join(@tombstone_prefix, path))
|
||||
.copy_from(copy_source: File.join(@s3_bucket, path))
|
||||
.object(File.join(@tombstone_prefix, tombstone_filename))
|
||||
.copy_from(copy_source: File.join(@s3_bucket, s3_filename))
|
||||
end
|
||||
|
||||
# delete the file
|
||||
bucket.object(path).delete
|
||||
bucket.object(s3_filename).delete
|
||||
rescue Aws::S3::Errors::NoSuchKey
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user