@ -13,26 +13,16 @@ import (
// executeUnifiedCopyStrategy executes the appropriate copy strategy based on encryption state
// executeUnifiedCopyStrategy executes the appropriate copy strategy based on encryption state
// Returns chunks and destination metadata that should be applied to the destination entry
// Returns chunks and destination metadata that should be applied to the destination entry
func ( s3a * S3ApiServer ) executeUnifiedCopyStrategy ( entry * filer_pb . Entry , r * http . Request , dstBucket , srcObject , dstObject string ) ( [ ] * filer_pb . FileChunk , map [ string ] [ ] byte , error ) {
func ( s3a * S3ApiServer ) executeUnifiedCopyStrategy ( entry * filer_pb . Entry , r * http . Request , srcBucket , dstBucket , srcObject , dstObject string ) ( [ ] * filer_pb . FileChunk , map [ string ] [ ] byte , error ) {
// Detect encryption state (using entry-aware detection for multipart objects)
// Detect encryption state (using entry-aware detection for multipart objects)
srcPath := fmt . Sprintf ( "%s/%s/%s" , s3a . option . BucketsPath , r . Heade r. Get ( "X-Amz-Copy-Source- Bucket" ) , srcObject )
srcPath := fmt . Sprintf ( "%s/%s/%s" , s3a . option . BucketsPath , s rc Bucket, srcObject )
dstPath := fmt . Sprintf ( "%s/%s/%s" , s3a . option . BucketsPath , dstBucket , dstObject )
dstPath := fmt . Sprintf ( "%s/%s/%s" , s3a . option . BucketsPath , dstBucket , dstObject )
state := DetectEncryptionStateWithEntry ( entry , r , srcPath , dstPath )
state := DetectEncryptionStateWithEntry ( entry , r , srcPath , dstPath )
// Debug logging for encryption state
// Debug logging for encryption state
// Apply bucket default encryption if no explicit encryption specified
// Apply bucket default encryption if no explicit encryption specified
if ! state . IsTargetEncrypted ( ) {
bucketMetadata , err := s3a . getBucketMetadata ( dstBucket )
if err == nil && bucketMetadata != nil && bucketMetadata . Encryption != nil {
switch bucketMetadata . Encryption . SseAlgorithm {
case "aws:kms" :
state . DstSSEKMS = true
case "AES256" :
state . DstSSES3 = true
}
}
}
s3a . applyCopyBucketDefaultEncryption ( state , dstBucket )
// Determine copy strategy
// Determine copy strategy
strategy , err := DetermineUnifiedCopyStrategy ( state , entry . Extended , r )
strategy , err := DetermineUnifiedCopyStrategy ( state , entry . Extended , r )
@ -169,3 +159,18 @@ func (s3a *S3ApiServer) executeReencryptCopy(entry *filer_pb.Entry, r *http.Requ
glog . V ( 2 ) . Infof ( "Cross-encryption copy: using unified multipart copy" )
glog . V ( 2 ) . Infof ( "Cross-encryption copy: using unified multipart copy" )
return s3a . copyMultipartCrossEncryption ( entry , r , state , dstBucket , dstPath )
return s3a . copyMultipartCrossEncryption ( entry , r , state , dstBucket , dstPath )
}
}
// applyCopyBucketDefaultEncryption applies the destination bucket's default encryption settings if no explicit encryption is specified
func ( s3a * S3ApiServer ) applyCopyBucketDefaultEncryption ( state * EncryptionState , dstBucket string ) {
if ! state . IsTargetEncrypted ( ) {
bucketMetadata , err := s3a . getBucketMetadata ( dstBucket )
if err == nil && bucketMetadata != nil && bucketMetadata . Encryption != nil {
switch bucketMetadata . Encryption . SseAlgorithm {
case "aws:kms" :
state . DstSSEKMS = true
case "AES256" :
state . DstSSES3 = true
}
}
}
}