1
0
mirror of https://github.com/minio/minio synced 2024-07-05 17:08:43 +00:00

fix: do not update metadata cache upon headObject() (#19929)

This commit is contained in:
jiuker 2024-06-13 23:42:02 +08:00 committed by GitHub
parent 5a5046ce45
commit 62e6dc950d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -959,7 +959,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
// No need to check cache for encrypted objects.
cachedResult = false
}
var update bool
if cachedResult {
rc := &cache.CondCheck{}
h := r.Header.Clone()
@ -968,7 +967,7 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
}
rc.Init(bucket, object, h)
ci, err := globalCacheConfig.Get(rc)
ci, _ := globalCacheConfig.Get(rc)
if ci != nil {
tgs, ok := ci.Metadata[xhttp.AmzObjectTagging]
if ok {
@ -1027,9 +1026,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
return
}
}
if errors.Is(err, cache.ErrKeyMissing) {
update = true
}
}
opts.FastGetObjInfo = true
@ -1053,10 +1049,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
}
}
}
if _, ok := crypto.IsEncrypted(objInfo.UserDefined); ok {
// Never store encrypted objects in cache.
update = false
}
if objInfo.UserTags != "" {
// Set this such that authorization policies can be applied on the object tags.
@ -1137,24 +1129,6 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
return
}
if update {
asize, err := objInfo.GetActualSize()
if err != nil {
asize = objInfo.Size
}
defer globalCacheConfig.Set(&cache.ObjectInfo{
Key: objInfo.Name,
Bucket: objInfo.Bucket,
ETag: objInfo.ETag,
ModTime: objInfo.ModTime,
Expires: objInfo.ExpiresStr(),
CacheControl: objInfo.CacheControl,
Size: asize,
Metadata: cleanReservedKeys(objInfo.UserDefined),
})
}
// Validate pre-conditions if any.
if checkPreconditions(ctx, w, r, objInfo, opts) {
return