s5cmd icon indicating copy to clipboard operation
s5cmd copied to clipboard

default for --metadata-directive on sync/copy does not match AWS CLI behavior

Open ezratweaver opened this issue 8 months ago • 0 comments

When syncing/copying from remote source -> remote destination metadata-directive defaults to 'REPLACE' instead of 'COPY', this breaks compatibility with AWS CLI, as the AWS CLI defaults to 'COPY' when syncing between remote sources.

Example:

# Expected behavior (AWS CLI compatible):
s5cmd sync s3://bucket-a/file s3://bucket-b/
# Should preserve original metadata (COPY)

# Current behavior:
# Replaces metadata (REPLACE)

Link to documentation of AWS CLI stating 'COPY' as the default here.

Code can be found here.

// command/cp.go lines 535-542

// ...rest of code
if c.metadataDirective == "" {
    // default to COPY
    c.metadataDirective = metadataDirectiveCopy
    if c.src.IsRemote() && c.dst.IsRemote() {
        // default to REPLACE when copying between remote storages
        c.metadataDirective = metadataDirectiveReplace
    }
}
// ...rest of  #code

This threw off my team when moving from AWS CLI, as we expected metadata to be preserved during remote-to-remote syncs. I would suggest removing the remote-to-remote condition and defaulting to COPY in all cases to match AWS CLI behavior.

ezratweaver avatar Jun 12 '25 13:06 ezratweaver