[#611] Process delimiters on the object info cache hit
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
aee7450880
commit
97f81d3270
1 changed files with 19 additions and 1 deletions
|
@ -672,8 +672,26 @@ func triageExtendedObjects(allObjects []*data.ExtendedObjectInfo) (prefixes []st
|
|||
|
||||
func (n *layer) objectInfoFromObjectsCacheOrNeoFS(ctx context.Context, bktInfo *data.BucketInfo, obj oid.ID, prefix, delimiter string) *data.ObjectInfo {
|
||||
if objInfo := n.objCache.GetObject(newAddress(bktInfo.CID, obj)); objInfo != nil {
|
||||
// that's the simplest solution
|
||||
// consider doing something else
|
||||
if !strings.HasPrefix(objInfo.Name, prefix) {
|
||||
return nil
|
||||
}
|
||||
if len(delimiter) == 0 {
|
||||
return objInfo
|
||||
}
|
||||
copiedObjInfo := *objInfo
|
||||
tail := strings.TrimPrefix(copiedObjInfo.Name, prefix)
|
||||
index := strings.Index(tail, delimiter)
|
||||
if index >= 0 {
|
||||
copiedObjInfo.IsDir = true
|
||||
copiedObjInfo.Size = 0
|
||||
copiedObjInfo.Headers = nil
|
||||
copiedObjInfo.ContentType = ""
|
||||
copiedObjInfo.Name = prefix + tail[:index+1]
|
||||
}
|
||||
return &copiedObjInfo
|
||||
}
|
||||
|
||||
meta, err := n.objectHead(ctx, bktInfo, obj)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue