Fix mc cp when legal-hold or retention is set (#3257)

- Send Content-MD5 header if default retention is set on the bucket
- legal-hold needs to be case insensitive
This commit is contained in:
poornas
2020-06-16 12:13:35 -07:00
committed by Harshavardhana
parent 707f46c32b
commit 397f41c71c
2 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -987,13 +987,19 @@ func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metada
if lockModeStr != "" {
opts.Mode = &lockMode
opts.SendContentMd5 = true
}
if lh, ok := metadata[AmzObjectLockLegalHold]; ok {
delete(metadata, AmzObjectLockLegalHold)
opts.LegalHold = minio.LegalHoldStatus(strings.ToUpper(lh))
opts.SendContentMd5 = true
}
if opts.LegalHold == "" && opts.Mode == nil {
if _, _, _, err := c.api.GetBucketObjectLockConfig(bucket); err == nil {
opts.SendContentMd5 = true
}
}
n, e := c.api.PutObjectWithContext(ctx, bucket, object, reader, size, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
+3 -3
View File
@@ -478,7 +478,7 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p
cpURLs.TargetContent.RetentionEnabled = true
}
cpURLs.TargetContent.RetentionDuration = session.Header.CommandStringFlags[rdFlag]
cpURLs.TargetContent.LegalHold = session.Header.CommandStringFlags[lhFlag]
cpURLs.TargetContent.LegalHold = strings.ToUpper(session.Header.CommandStringFlags[lhFlag])
if cpURLs.TargetContent.LegalHold != "" {
cpURLs.TargetContent.LegalHoldEnabled = true
}
@@ -491,7 +491,7 @@ func doCopySession(cli *cli.Context, session *sessionV8, encKeyDB map[string][]p
cpURLs.TargetContent.RetentionDuration = rd
}
if lh := cli.String(lhFlag); lh != "" {
cpURLs.TargetContent.LegalHold = lh
cpURLs.TargetContent.LegalHold = strings.ToUpper(lh)
cpURLs.TargetContent.LegalHoldEnabled = true
}
}
@@ -642,7 +642,7 @@ func mainCopy(ctx *cli.Context) error {
storageClass := ctx.String("storage-class")
retentionMode := ctx.String(rmFlag)
retentionDuration := ctx.String(rdFlag)
legalHold := ctx.String(lhFlag)
legalHold := strings.ToUpper(ctx.String(lhFlag))
sseKeys := os.Getenv("MC_ENCRYPT_KEY")
if key := ctx.String("encrypt-key"); key != "" {
sseKeys = key