Skip to content

Commit

Permalink
S3: clone putUserMetadata map to prevent concurrent modification
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Asp <[email protected]>
  • Loading branch information
andyasp committed Sep 21, 2023
1 parent cac7ba2 commit ff39b16
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
if size < int64(partSize) {
partSize = 0
}

// Cloning map since minio may modify it
userMetadata := make(map[string]string, len(b.putUserMetadata))
for k, v := range b.putUserMetadata {
userMetadata[k] = v
}

if _, err := b.client.PutObject(
ctx,
b.name,
Expand All @@ -501,7 +508,7 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
minio.PutObjectOptions{
PartSize: partSize,
ServerSideEncryption: sse,
UserMetadata: b.putUserMetadata,
UserMetadata: userMetadata,
StorageClass: b.storageClass,
// 4 is what minio-go have as the default. To be certain we do micro benchmark before any changes we
// ensure we pin this number to four.
Expand Down

0 comments on commit ff39b16

Please sign in to comment.