fix: copy object missing prefix on metadata delete

When using the REPLACE directive, we were incorrectly removing the
old metadata on the object due to missing the metadata prefix on
the key.  Fix this to remove the correct metadata before setting
new metadata.

Fixes #787
This commit is contained in:
Ben McClelland
2024-09-07 17:06:45 -07:00
parent 66a7879b0a
commit ccd4166b2e
3 changed files with 62 additions and 10 deletions
+3 -2
View File
@@ -2038,8 +2038,9 @@ func (p *Posix) CopyObject(ctx context.Context, input *s3.CopyObjectInput) (*s3.
return &s3.CopyObjectOutput{}, s3err.GetAPIError(s3err.ErrInvalidCopyDest)
}
for key := range mdmap {
err := p.meta.DeleteAttribute(dstBucket, dstObject, key)
for k := range mdmap {
err := p.meta.DeleteAttribute(dstBucket, dstObject,
fmt.Sprintf("%v.%v", metaHdr, k))
if err != nil && !errors.Is(err, meta.ErrNoSuchKey) {
return nil, fmt.Errorf("delete user metadata: %w", err)
}