diff --git a/api/layer/object.go b/api/layer/object.go index 932945ab..b37df3c4 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -282,6 +282,7 @@ func (n *layer) ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*Lis if p.ContinuationToken != "" { allObjects = n.cache.GetCache(p.ContinuationToken, cacheKey) + allObjects = trimStartAfter(p.StartAfter, allObjects) } if allObjects == nil { @@ -369,3 +370,14 @@ func (n *layer) listSortedAllObjects(ctx context.Context, p allObjectParams) ([] return objects, nil } + +func trimStartAfter(startAfter string, objects []*ObjectInfo) []*ObjectInfo { + if objects != nil && len(startAfter) != 0 && objects[0].Name <= startAfter { + for i := range objects { + if objects[i].Name > startAfter { + return objects[i:] + } + } + } + return objects +}