mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
Copy metadata on update (#8755)
Fixes #8706 Co-authored-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
parent
ae0b165431
commit
fe379f9428
@ -595,16 +595,32 @@ func checkPutObjectRetentionAllowed(ctx context.Context, r *http.Request, bucket
|
|||||||
|
|
||||||
// filter object lock metadata if s3:GetObjectRetention permission is denied or if isCopy flag set.
|
// filter object lock metadata if s3:GetObjectRetention permission is denied or if isCopy flag set.
|
||||||
func filterObjectLockMetadata(ctx context.Context, r *http.Request, bucket, object string, metadata map[string]string, isCopy bool, getRetPerms APIErrorCode) map[string]string {
|
func filterObjectLockMetadata(ctx context.Context, r *http.Request, bucket, object string, metadata map[string]string, isCopy bool, getRetPerms APIErrorCode) map[string]string {
|
||||||
|
// Copy on write
|
||||||
|
dst := metadata
|
||||||
|
var copied bool
|
||||||
|
delKey := func(key string) {
|
||||||
|
if _, ok := metadata[key]; !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !copied {
|
||||||
|
dst = make(map[string]string, len(metadata))
|
||||||
|
for k, v := range metadata {
|
||||||
|
dst[k] = v
|
||||||
|
}
|
||||||
|
copied = true
|
||||||
|
}
|
||||||
|
delete(dst, key)
|
||||||
|
}
|
||||||
ret := getObjectRetentionMeta(metadata)
|
ret := getObjectRetentionMeta(metadata)
|
||||||
if ret.Mode == Invalid || isCopy {
|
if ret.Mode == Invalid || isCopy {
|
||||||
delete(metadata, xhttp.AmzObjectLockMode)
|
delKey(xhttp.AmzObjectLockMode)
|
||||||
delete(metadata, xhttp.AmzObjectLockRetainUntilDate)
|
delKey(xhttp.AmzObjectLockRetainUntilDate)
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
if getRetPerms == ErrNone {
|
if getRetPerms == ErrNone {
|
||||||
return metadata
|
return dst
|
||||||
}
|
}
|
||||||
delete(metadata, xhttp.AmzObjectLockMode)
|
delKey(xhttp.AmzObjectLockMode)
|
||||||
delete(metadata, xhttp.AmzObjectLockRetainUntilDate)
|
delKey(xhttp.AmzObjectLockRetainUntilDate)
|
||||||
return metadata
|
return dst
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user