Avoid overwriting object tags when changing lock (#9794)

master
poornas 4 years ago committed by GitHub
parent 142b057be8
commit 3d3b75fb8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      cmd/object-handlers.go
  2. 2
      cmd/storage-datatypes.go

@ -2699,8 +2699,11 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
return
}
objInfo.UserDefined[strings.ToLower(xhttp.AmzObjectLockLegalHold)] = strings.ToUpper(string(legalHold.Status))
if objInfo.UserTags != "" {
objInfo.UserDefined[xhttp.AmzTagDirective] = replaceDirective
objInfo.UserDefined[xhttp.AmzObjectTagging] = objInfo.UserTags
}
objInfo.metadataOnly = true
if _, err = objectAPI.CopyObject(ctx, bucket, object, bucket, object, objInfo, ObjectOptions{}, ObjectOptions{}); err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
return
@ -2857,6 +2860,10 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r
objInfo.UserDefined[strings.ToLower(xhttp.AmzObjectLockMode)] = string(objRetention.Mode)
objInfo.UserDefined[strings.ToLower(xhttp.AmzObjectLockRetainUntilDate)] = objRetention.RetainUntilDate.UTC().Format(time.RFC3339)
if objInfo.UserTags != "" {
objInfo.UserDefined[xhttp.AmzTagDirective] = replaceDirective
objInfo.UserDefined[xhttp.AmzObjectTagging] = objInfo.UserTags
}
objInfo.metadataOnly = true // Perform only metadata updates.
if _, err = objectAPI.CopyObject(ctx, bucket, object, bucket, object, objInfo, ObjectOptions{}, ObjectOptions{}); err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))

@ -85,7 +85,7 @@ func (entry FileInfo) ToObjectInfo() ObjectInfo {
ContentEncoding: entry.Metadata["content-encoding"],
}
// Extrat object tagging information
// Extract object tagging information
objInfo.UserTags = entry.Metadata[xhttp.AmzObjectTagging]
// Extract etag from metadata.

Loading…
Cancel
Save