From 02729731751f5da35cb5e99669a8949169bbeb71 Mon Sep 17 00:00:00 2001 From: poornas Date: Tue, 18 Aug 2020 12:09:42 -0700 Subject: [PATCH] Fix regression in web ui for retention (#10285) Fixes: #10283 regression from PR #9259 --- cmd/web-handlers.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cmd/web-handlers.go b/cmd/web-handlers.go index fe9f98efc..36e622617 100644 --- a/cmd/web-handlers.go +++ b/cmd/web-handlers.go @@ -1130,9 +1130,6 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) { // Ensure that metadata does not contain sensitive information crypto.RemoveSensitiveEntries(metadata) - retentionRequested := objectlock.IsObjectLockRetentionRequested(r.Header) - legalHoldRequested := objectlock.IsObjectLockLegalHoldRequested(r.Header) - putObject := objectAPI.PutObject getObjectInfo := objectAPI.GetObjectInfo if web.CacheAPI() != nil { @@ -1140,20 +1137,15 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) { getObjectInfo = web.CacheAPI().GetObjectInfo } - if retentionRequested || legalHoldRequested { - // enforce object retention rules - retentionMode, retentionDate, legalHold, s3Err := checkPutObjectLockAllowed(ctx, r, bucket, object, getObjectInfo, retPerms, holdPerms) - if s3Err == ErrNone && retentionMode != "" { - opts.UserDefined[xhttp.AmzObjectLockMode] = string(retentionMode) - opts.UserDefined[xhttp.AmzObjectLockRetainUntilDate] = retentionDate.UTC().Format(iso8601TimeFormat) - } - if s3Err == ErrNone && legalHold.Status != "" { - opts.UserDefined[xhttp.AmzObjectLockLegalHold] = string(legalHold.Status) - } - if s3Err != ErrNone { - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL, guessIsBrowserReq(r)) - return - } + // enforce object retention rules + retentionMode, retentionDate, _, s3Err := checkPutObjectLockAllowed(ctx, r, bucket, object, getObjectInfo, retPerms, holdPerms) + if s3Err != ErrNone { + writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL, guessIsBrowserReq(r)) + return + } + if retentionMode != "" { + opts.UserDefined[xhttp.AmzObjectLockMode] = string(retentionMode) + opts.UserDefined[xhttp.AmzObjectLockRetainUntilDate] = retentionDate.UTC().Format(iso8601TimeFormat) } objInfo, err := putObject(GlobalContext, bucket, object, pReader, opts)