[#165] Fix v1 listing bookmark

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-01-21 00:39:03 +03:00
parent 0ae49eaab0
commit 6d52f46012

View file

@ -80,6 +80,7 @@ type (
MaxKeys int
Marker string
Bookmark string
VersionAPi string
}
)
@ -94,6 +95,7 @@ func (n *layer) ListObjectsV1(ctx context.Context, p *ListObjectsParamsV1) (*Lis
MaxKeys: p.MaxKeys,
Marker: p.Marker,
Bookmark: p.Marker,
VersionAPi: "v1",
}
objects, next, err := n.getLatestObjectsVersions(ctx, prm)
@ -122,6 +124,7 @@ func (n *layer) ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*Lis
MaxKeys: p.MaxKeys,
Marker: p.StartAfter,
Bookmark: p.ContinuationToken,
VersionAPi: "v2",
}
objects, next, err := n.getLatestObjectsVersions(ctx, prm)
@ -147,6 +150,7 @@ func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsPar
MaxKeys: p.MaxKeys,
Marker: p.KeyMarker,
Bookmark: p.VersionIDMarker,
VersionAPi: "vs",
}
objects, isTruncated, err := n.getAllObjectsVersions(ctx, prm)
@ -223,8 +227,12 @@ func (n *layer) getLatestObjectsVersions(ctx context.Context, p allObjectListing
if next != nil {
session.Next = []*data.NodeVersion{next}
if p.VersionAPi == "v1" {
n.cache.PutListSession(owner, cache.CreateListSessionCacheKey(p.BktInfo.CID, p.Prefix, objects[len(objects)-1].FilePath), session)
} else {
n.cache.PutListSession(owner, cache.CreateListSessionCacheKey(p.BktInfo.CID, p.Prefix, next.OID.EncodeToString()), session)
}
}
return
}