avoid calling get bucket object lock config for same bucket (#3378)

This commit is contained in:
Harshavardhana
2020-08-25 10:50:40 -07:00
committed by GitHub
parent b1ca6482d5
commit c58148a421
3 changed files with 25 additions and 10 deletions
+1 -5
View File
@@ -1004,11 +1004,7 @@ func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metada
opts.LegalHold = minio.LegalHoldStatus(strings.ToUpper(lh))
opts.SendContentMd5 = true
}
if opts.LegalHold == "" && opts.Mode == "" {
if _, _, _, err := c.api.GetBucketObjectLockConfig(ctx, bucket); err == nil {
opts.SendContentMd5 = true
}
}
ui, e := c.api.PutObject(ctx, bucket, object, reader, size, opts)
if e != nil {
errResponse := minio.ToErrorResponse(e)
+13 -4
View File
@@ -370,6 +370,18 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
pg = newAccounter(totalBytes)
}
sourceURLs := cli.Args()[:len(cli.Args())-1]
targetURL := cli.Args()[len(cli.Args())-1] // Last one is target
tgtClnt, err := newClient(targetURL)
fatalIf(err, "Unable to initialize `"+targetURL+"`.")
// Check if the target bucket has object locking enabled
var withLock bool
if _, _, _, err = tgtClnt.GetObjectLockConfig(ctx); err == nil {
withLock = true
}
if session != nil {
// isCopied returns true if an object has been already copied
// or not. This is useful when we resume from a session.
@@ -403,9 +415,6 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
}()
} else {
sourceURLs := cli.Args()[:len(cli.Args())-1]
targetURL := cli.Args()[len(cli.Args())-1] // Last one is target
// Access recursive flag inside the session header.
isRecursive := cli.Bool("recursive")
olderThan := cli.String("older-than")
@@ -517,7 +526,7 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
}
}
cpURLs.MD5 = cli.Bool("md5")
cpURLs.MD5 = cli.Bool("md5") || withLock
cpURLs.DisableMultipart = cli.Bool("disable-multipart")
// Verify if previously copied, notify progress bar.
+11 -1
View File
@@ -807,8 +807,15 @@ func runMirror(ctx context.Context, cancelMirror context.CancelFunc, srcURL, dst
}
// object lock configuration set on bucket
if mode != "" {
errorIf(newDstClt.SetObjectLockConfig(ctx, mode, validity, unit),
err = newDstClt.SetObjectLockConfig(ctx, mode, validity, unit)
errorIf(err,
"Unable to set object lock config in `"+newTgtURL+"`.")
if err != nil && mj.opts.activeActive {
return true
}
if err == nil {
mj.opts.md5 = true
}
}
errorIf(copyBucketPolicies(ctx, newSrcClt, newDstClt, isOverwrite),
"Unable to copy bucket policies to `"+newDstClt.GetURL().String()+"`.")
@@ -853,6 +860,9 @@ func runMirror(ctx context.Context, cancelMirror context.CancelFunc, srcURL, dst
if err != nil && mj.opts.activeActive {
return true
}
if err == nil {
mj.opts.md5 = true
}
}
err = copyBucketPolicies(ctx, srcClt, dstClt, isOverwrite)