[#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

@ -74,12 +74,13 @@ type (
} }
allObjectListingParams struct { allObjectListingParams struct {
BktInfo *data.BucketInfo BktInfo *data.BucketInfo
Delimiter string Delimiter string
Prefix string Prefix string
MaxKeys int MaxKeys int
Marker string Marker string
Bookmark string Bookmark string
VersionAPi string
} }
) )
@ -88,12 +89,13 @@ func (n *layer) ListObjectsV1(ctx context.Context, p *ListObjectsParamsV1) (*Lis
var result ListObjectsInfoV1 var result ListObjectsInfoV1
prm := allObjectListingParams{ prm := allObjectListingParams{
BktInfo: p.BktInfo, BktInfo: p.BktInfo,
Delimiter: p.Delimiter, Delimiter: p.Delimiter,
Prefix: p.Prefix, Prefix: p.Prefix,
MaxKeys: p.MaxKeys, MaxKeys: p.MaxKeys,
Marker: p.Marker, Marker: p.Marker,
Bookmark: p.Marker, Bookmark: p.Marker,
VersionAPi: "v1",
} }
objects, next, err := n.getLatestObjectsVersions(ctx, prm) objects, next, err := n.getLatestObjectsVersions(ctx, prm)
@ -116,12 +118,13 @@ func (n *layer) ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*Lis
var result ListObjectsInfoV2 var result ListObjectsInfoV2
prm := allObjectListingParams{ prm := allObjectListingParams{
BktInfo: p.BktInfo, BktInfo: p.BktInfo,
Delimiter: p.Delimiter, Delimiter: p.Delimiter,
Prefix: p.Prefix, Prefix: p.Prefix,
MaxKeys: p.MaxKeys, MaxKeys: p.MaxKeys,
Marker: p.StartAfter, Marker: p.StartAfter,
Bookmark: p.ContinuationToken, Bookmark: p.ContinuationToken,
VersionAPi: "v2",
} }
objects, next, err := n.getLatestObjectsVersions(ctx, prm) objects, next, err := n.getLatestObjectsVersions(ctx, prm)
@ -141,12 +144,13 @@ func (n *layer) ListObjectsV2(ctx context.Context, p *ListObjectsParamsV2) (*Lis
func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error) { func (n *layer) ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error) {
prm := allObjectListingParams{ prm := allObjectListingParams{
BktInfo: p.BktInfo, BktInfo: p.BktInfo,
Delimiter: p.Delimiter, Delimiter: p.Delimiter,
Prefix: p.Prefix, Prefix: p.Prefix,
MaxKeys: p.MaxKeys, MaxKeys: p.MaxKeys,
Marker: p.KeyMarker, Marker: p.KeyMarker,
Bookmark: p.VersionIDMarker, Bookmark: p.VersionIDMarker,
VersionAPi: "vs",
} }
objects, isTruncated, err := n.getAllObjectsVersions(ctx, prm) objects, isTruncated, err := n.getAllObjectsVersions(ctx, prm)
@ -223,7 +227,11 @@ func (n *layer) getLatestObjectsVersions(ctx context.Context, p allObjectListing
if next != nil { if next != nil {
session.Next = []*data.NodeVersion{next} session.Next = []*data.NodeVersion{next}
n.cache.PutListSession(owner, cache.CreateListSessionCacheKey(p.BktInfo.CID, p.Prefix, next.OID.EncodeToString()), session) 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 return