[#488] Sync using cid.ID

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-06-27 12:08:26 +03:00 committed by Alex Vanin
parent 5c8a927c36
commit 85c203e157
26 changed files with 204 additions and 207 deletions

View file

@ -122,7 +122,7 @@ func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string,
} }
// CreateObjectsListCacheKey returns ObjectsListKey with the given CID, prefix and latestOnly flag. // CreateObjectsListCacheKey returns ObjectsListKey with the given CID, prefix and latestOnly flag.
func CreateObjectsListCacheKey(cnr *cid.ID, prefix string, latestOnly bool) ObjectsListKey { func CreateObjectsListCacheKey(cnr cid.ID, prefix string, latestOnly bool) ObjectsListKey {
p := ObjectsListKey{ p := ObjectsListKey{
cid: cnr.EncodeToString(), cid: cnr.EncodeToString(),
prefix: prefix, prefix: prefix,

View file

@ -40,7 +40,7 @@ type BaseNodeVersion struct {
} }
type ObjectTaggingInfo struct { type ObjectTaggingInfo struct {
CnrID *cid.ID CnrID cid.ID
ObjName string ObjName string
VersionID string VersionID string
} }

View file

@ -51,7 +51,7 @@ func prepareHandlerContext(t *testing.T) *handlerContext {
tp := layer.NewTestNeoFS() tp := layer.NewTestNeoFS()
testResolver := &resolver.BucketResolver{Name: "test_resolver"} testResolver := &resolver.BucketResolver{Name: "test_resolver"}
testResolver.SetResolveFunc(func(_ context.Context, name string) (*cid.ID, error) { testResolver.SetResolveFunc(func(_ context.Context, name string) (cid.ID, error) {
return tp.ContainerID(name) return tp.ContainerID(name)
}) })
@ -93,7 +93,7 @@ func createTestBucketWithLock(ctx context.Context, t *testing.T, h *handlerConte
var ownerID user.ID var ownerID user.ID
bktInfo := &data.BucketInfo{ bktInfo := &data.BucketInfo{
CID: *cnrID, CID: cnrID,
Name: bktName, Name: bktName,
ObjectLockEnabled: true, ObjectLockEnabled: true,
Owner: ownerID, Owner: ownerID,

View file

@ -663,7 +663,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
} }
if err = h.obj.PutBucketSettings(r.Context(), sp); err != nil { if err = h.obj.PutBucketSettings(r.Context(), sp); err != nil {
h.logAndSendError(w, "couldn't enable bucket versioning", reqInfo, err, h.logAndSendError(w, "couldn't enable bucket versioning", reqInfo, err,
zap.Stringer("container_id", bktInfo.CID)) zap.String("container_id", bktInfo.CID.EncodeToString()))
return return
} }
} }

View file

@ -149,7 +149,7 @@ func (h *handler) PutBucketTaggingHandler(w http.ResponseWriter, r *http.Request
return return
} }
if err = h.obj.PutBucketTagging(r.Context(), &bktInfo.CID, tagSet); err != nil { if err = h.obj.PutBucketTagging(r.Context(), bktInfo.CID, tagSet); err != nil {
h.logAndSendError(w, "could not put object tagging", reqInfo, err) h.logAndSendError(w, "could not put object tagging", reqInfo, err)
return return
} }
@ -164,7 +164,7 @@ func (h *handler) GetBucketTaggingHandler(w http.ResponseWriter, r *http.Request
return return
} }
tagSet, err := h.obj.GetBucketTagging(r.Context(), &bktInfo.CID) tagSet, err := h.obj.GetBucketTagging(r.Context(), bktInfo.CID)
if err != nil { if err != nil {
h.logAndSendError(w, "could not get object tagging", reqInfo, err) h.logAndSendError(w, "could not get object tagging", reqInfo, err)
return return
@ -185,7 +185,7 @@ func (h *handler) DeleteBucketTaggingHandler(w http.ResponseWriter, r *http.Requ
return return
} }
if err = h.obj.DeleteBucketTagging(r.Context(), &bktInfo.CID); err != nil { if err = h.obj.DeleteBucketTagging(r.Context(), bktInfo.CID); err != nil {
h.logAndSendError(w, "could not delete bucket tagging", reqInfo, err) h.logAndSendError(w, "could not delete bucket tagging", reqInfo, err)
return return
} }

View file

@ -28,7 +28,7 @@ func (n *layer) GetObjectTaggingAndLock(ctx context.Context, objVersion *ObjectV
} }
objVersion.VersionID = version.OID.EncodeToString() objVersion.VersionID = version.OID.EncodeToString()
tags, lockInfo, err = n.treeService.GetObjectTaggingAndLock(ctx, &objVersion.BktInfo.CID, version) tags, lockInfo, err = n.treeService.GetObjectTaggingAndLock(ctx, objVersion.BktInfo.CID, version)
if err != nil { if err != nil {
if errorsStd.Is(err, ErrNodeNotFound) { if errorsStd.Is(err, ErrNodeNotFound) {
return nil, nil, errors.GetAPIError(errors.ErrNoSuchKey) return nil, nil, errors.GetAPIError(errors.ErrNoSuchKey)

View file

@ -146,7 +146,7 @@ func (n *layer) createContainer(ctx context.Context, p *CreateBucketParams) (*da
return nil, fmt.Errorf("create container: %w", err) return nil, fmt.Errorf("create container: %w", err)
} }
bktInfo.CID = *idCnr bktInfo.CID = idCnr
if err = n.setContainerEACLTable(ctx, bktInfo.CID, p.EACL, p.SessionEACL); err != nil { if err = n.setContainerEACLTable(ctx, bktInfo.CID, p.EACL, p.SessionEACL); err != nil {
return nil, fmt.Errorf("set container eacl: %w", err) return nil, fmt.Errorf("set container eacl: %w", err)

View file

@ -48,7 +48,7 @@ func (n *layer) PutBucketCORS(ctx context.Context, p *PutCORSParams) error {
return fmt.Errorf("put system object: %w", err) return fmt.Errorf("put system object: %w", err)
} }
objIDToDelete, err := n.treeService.PutBucketCORS(ctx, &p.BktInfo.CID, objID) objIDToDelete, err := n.treeService.PutBucketCORS(ctx, p.BktInfo.CID, objID)
if err != nil { if err != nil {
return err return err
} }
@ -82,7 +82,7 @@ func (n *layer) GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) (*d
} }
func (n *layer) DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) error { func (n *layer) DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) error {
objID, err := n.treeService.DeleteBucketCORS(ctx, &bktInfo.CID) objID, err := n.treeService.DeleteBucketCORS(ctx, bktInfo.CID)
if err != nil { if err != nil {
return err return err
} }

View file

@ -220,9 +220,9 @@ type (
GetLockInfo(ctx context.Context, obj *ObjectVersion) (*data.LockInfo, error) GetLockInfo(ctx context.Context, obj *ObjectVersion) (*data.LockInfo, error)
PutLockInfo(ctx context.Context, p *ObjectVersion, lock *data.ObjectLock) error PutLockInfo(ctx context.Context, p *ObjectVersion, lock *data.ObjectLock) error
GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string]string, error) GetBucketTagging(ctx context.Context, cnrID cid.ID) (map[string]string, error)
PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error PutBucketTagging(ctx context.Context, cnrID cid.ID, tagSet map[string]string) error
DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error DeleteBucketTagging(ctx context.Context, cnrID cid.ID) error
GetObjectTagging(ctx context.Context, p *ObjectVersion) (string, map[string]string, error) GetObjectTagging(ctx context.Context, p *ObjectVersion) (string, map[string]string, error)
PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet map[string]string) error PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet map[string]string) error
@ -363,7 +363,7 @@ func (n *layer) GetBucketInfo(ctx context.Context, name string) (*data.BucketInf
return nil, errors.GetAPIError(errors.ErrNoSuchBucket) return nil, errors.GetAPIError(errors.ErrNoSuchBucket)
} }
return n.containerInfo(ctx, *containerID) return n.containerInfo(ctx, containerID)
} }
// GetBucketACL returns bucket acl info by name. // GetBucketACL returns bucket acl info by name.
@ -515,7 +515,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, obj *Ver
IsUnversioned: true, IsUnversioned: true,
} }
if obj.Error = n.treeService.AddVersion(ctx, &bkt.CID, newVersion); obj.Error != nil { if obj.Error = n.treeService.AddVersion(ctx, bkt.CID, newVersion); obj.Error != nil {
return obj return obj
} }
@ -529,7 +529,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, obj *Ver
return obj return obj
} }
if obj.Error = n.treeService.RemoveVersion(ctx, &bkt.CID, nodeVersion.ID); obj.Error != nil { if obj.Error = n.treeService.RemoveVersion(ctx, bkt.CID, nodeVersion.ID); obj.Error != nil {
return obj return obj
} }
} }
@ -572,13 +572,13 @@ func (n *layer) CreateBucket(ctx context.Context, p *CreateBucketParams) (*data.
return nil, errors.GetAPIError(errors.ErrBucketAlreadyExists) return nil, errors.GetAPIError(errors.ErrBucketAlreadyExists)
} }
func (n *layer) ResolveBucket(ctx context.Context, name string) (*cid.ID, error) { func (n *layer) ResolveBucket(ctx context.Context, name string) (cid.ID, error) {
var cnrID cid.ID var cnrID cid.ID
if err := cnrID.DecodeString(name); err != nil { if err := cnrID.DecodeString(name); err != nil {
return n.resolver.Resolve(ctx, name) return n.resolver.Resolve(ctx, name)
} }
return &cnrID, nil return cnrID, nil
} }
func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error { func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {

View file

@ -153,11 +153,11 @@ func (n *layer) CreateMultipartUpload(ctx context.Context, p *CreateMultipartPar
} }
} }
return n.treeService.CreateMultipartUpload(ctx, &p.Info.Bkt.CID, info) return n.treeService.CreateMultipartUpload(ctx, p.Info.Bkt.CID, info)
} }
func (n *layer) UploadPart(ctx context.Context, p *UploadPartParams) (string, error) { func (n *layer) UploadPart(ctx context.Context, p *UploadPartParams) (string, error) {
multipartInfo, err := n.treeService.GetMultipartUpload(ctx, &p.Info.Bkt.CID, p.Info.Key, p.Info.UploadID) multipartInfo, err := n.treeService.GetMultipartUpload(ctx, p.Info.Bkt.CID, p.Info.Key, p.Info.UploadID)
if err != nil { if err != nil {
if stderrors.Is(err, ErrNodeNotFound) { if stderrors.Is(err, ErrNodeNotFound) {
return "", errors.GetAPIError(errors.ErrNoSuchUpload) return "", errors.GetAPIError(errors.ErrNoSuchUpload)
@ -204,7 +204,7 @@ func (n *layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
Created: time.Now(), Created: time.Now(),
} }
oldPartID, err := n.treeService.AddPart(ctx, &bktInfo.CID, multipartInfo.ID, partInfo) oldPartID, err := n.treeService.AddPart(ctx, bktInfo.CID, multipartInfo.ID, partInfo)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -232,7 +232,7 @@ func (n *layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
} }
func (n *layer) UploadPartCopy(ctx context.Context, p *UploadCopyParams) (*data.ObjectInfo, error) { func (n *layer) UploadPartCopy(ctx context.Context, p *UploadCopyParams) (*data.ObjectInfo, error) {
multipartInfo, err := n.treeService.GetMultipartUpload(ctx, &p.Info.Bkt.CID, p.Info.Key, p.Info.UploadID) multipartInfo, err := n.treeService.GetMultipartUpload(ctx, p.Info.Bkt.CID, p.Info.Key, p.Info.UploadID)
if err != nil { if err != nil {
if stderrors.Is(err, ErrNodeNotFound) { if stderrors.Is(err, ErrNodeNotFound) {
return nil, errors.GetAPIError(errors.ErrNoSuchUpload) return nil, errors.GetAPIError(errors.ErrNoSuchUpload)
@ -403,14 +403,14 @@ func (n *layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
if err = n.objectDelete(ctx, p.Info.Bkt, partInfo.OID); err != nil { if err = n.objectDelete(ctx, p.Info.Bkt, partInfo.OID); err != nil {
n.log.Warn("could not delete upload part", n.log.Warn("could not delete upload part",
zap.Stringer("object id", &partInfo.OID), zap.Stringer("object id", &partInfo.OID),
zap.Stringer("bucket id", &p.Info.Bkt.CID), zap.Stringer("bucket id", p.Info.Bkt.CID),
zap.Error(err)) zap.Error(err))
} }
addr.SetObject(partInfo.OID) addr.SetObject(partInfo.OID)
n.objCache.Delete(addr) n.objCache.Delete(addr)
} }
return uploadData, obj, n.treeService.DeleteMultipartUpload(ctx, &p.Info.Bkt.CID, multipartInfo.ID) return uploadData, obj, n.treeService.DeleteMultipartUpload(ctx, p.Info.Bkt.CID, multipartInfo.ID)
} }
func (n *layer) ListMultipartUploads(ctx context.Context, p *ListMultipartUploadsParams) (*ListMultipartUploadsInfo, error) { func (n *layer) ListMultipartUploads(ctx context.Context, p *ListMultipartUploadsParams) (*ListMultipartUploadsInfo, error) {
@ -419,7 +419,7 @@ func (n *layer) ListMultipartUploads(ctx context.Context, p *ListMultipartUpload
return &result, nil return &result, nil
} }
multipartInfos, err := n.treeService.GetMultipartUploadsByPrefix(ctx, &p.Bkt.CID, p.Prefix) multipartInfos, err := n.treeService.GetMultipartUploadsByPrefix(ctx, p.Bkt.CID, p.Prefix)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -486,7 +486,7 @@ func (n *layer) AbortMultipartUpload(ctx context.Context, p *UploadInfoParams) e
} }
} }
return n.treeService.DeleteMultipartUpload(ctx, &p.Bkt.CID, multipartInfo.ID) return n.treeService.DeleteMultipartUpload(ctx, p.Bkt.CID, multipartInfo.ID)
} }
func (n *layer) ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsInfo, error) { func (n *layer) ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsInfo, error) {
@ -534,7 +534,7 @@ func (n *layer) ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsIn
} }
func (n *layer) getUploadParts(ctx context.Context, p *UploadInfoParams) (*data.MultipartInfo, map[int]*data.PartInfo, error) { func (n *layer) getUploadParts(ctx context.Context, p *UploadInfoParams) (*data.MultipartInfo, map[int]*data.PartInfo, error) {
multipartInfo, err := n.treeService.GetMultipartUpload(ctx, &p.Bkt.CID, p.Key, p.UploadID) multipartInfo, err := n.treeService.GetMultipartUpload(ctx, p.Bkt.CID, p.Key, p.UploadID)
if err != nil { if err != nil {
if stderrors.Is(err, ErrNodeNotFound) { if stderrors.Is(err, ErrNodeNotFound) {
return nil, nil, errors.GetAPIError(errors.ErrNoSuchUpload) return nil, nil, errors.GetAPIError(errors.ErrNoSuchUpload)
@ -542,7 +542,7 @@ func (n *layer) getUploadParts(ctx context.Context, p *UploadInfoParams) (*data.
return nil, nil, err return nil, nil, err
} }
parts, err := n.treeService.GetParts(ctx, &p.Bkt.CID, multipartInfo.ID) parts, err := n.treeService.GetParts(ctx, p.Bkt.CID, multipartInfo.ID)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -148,7 +148,7 @@ type NeoFS interface {
// //
// It returns exactly one non-nil value. It returns any error encountered which // It returns exactly one non-nil value. It returns any error encountered which
// prevented the container from being created. // prevented the container from being created.
CreateContainer(context.Context, PrmContainerCreate) (*cid.ID, error) CreateContainer(context.Context, PrmContainerCreate) (cid.ID, error)
// Container reads a container from NeoFS by ID. // Container reads a container from NeoFS by ID.
// //

View file

@ -54,17 +54,17 @@ func (t *TestNeoFS) AddObject(key string, obj *object.Object) {
t.objects[key] = obj t.objects[key] = obj
} }
func (t *TestNeoFS) ContainerID(name string) (*cid.ID, error) { func (t *TestNeoFS) ContainerID(name string) (cid.ID, error) {
for id, cnr := range t.containers { for id, cnr := range t.containers {
if container.Name(*cnr) == name { if container.Name(*cnr) == name {
var cnrID cid.ID var cnrID cid.ID
return &cnrID, cnrID.DecodeString(id) return cnrID, cnrID.DecodeString(id)
} }
} }
return nil, fmt.Errorf("not found") return cid.ID{}, fmt.Errorf("not found")
} }
func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) (*cid.ID, error) { func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) (cid.ID, error) {
var cnr container.Container var cnr container.Container
cnr.Init() cnr.Init()
cnr.SetOwner(prm.Creator) cnr.SetOwner(prm.Creator)
@ -86,14 +86,14 @@ func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) (
b := make([]byte, 32) b := make([]byte, 32)
if _, err := io.ReadFull(rand.Reader, b); err != nil { if _, err := io.ReadFull(rand.Reader, b); err != nil {
return nil, err return cid.ID{}, err
} }
var id cid.ID var id cid.ID
id.SetSHA256(sha256.Sum256(b)) id.SetSHA256(sha256.Sum256(b))
t.containers[id.EncodeToString()] = &cnr t.containers[id.EncodeToString()] = &cnr
return &id, nil return id, nil
} }
func (t *TestNeoFS) Container(_ context.Context, id cid.ID) (*container.Container, error) { func (t *TestNeoFS) Container(_ context.Context, id cid.ID) (*container.Container, error) {

View file

@ -38,7 +38,7 @@ func (n *layer) PutBucketNotificationConfiguration(ctx context.Context, p *PutBu
return err return err
} }
objIDToDelete, err := n.treeService.PutNotificationConfigurationNode(ctx, &p.BktInfo.CID, objID) objIDToDelete, err := n.treeService.PutNotificationConfigurationNode(ctx, p.BktInfo.CID, objID)
if err != nil { if err != nil {
return err return err
} }
@ -66,7 +66,7 @@ func (n *layer) GetBucketNotificationConfiguration(ctx context.Context, bktInfo
return conf, nil return conf, nil
} }
objID, err := n.treeService.GetNotificationConfigurationNode(ctx, &bktInfo.CID) objID, err := n.treeService.GetNotificationConfigurationNode(ctx, bktInfo.CID)
if err != nil && !errorsStd.Is(err, ErrNodeNotFound) { if err != nil && !errorsStd.Is(err, ErrNodeNotFound) {
return nil, err return nil, err
} }

View file

@ -190,7 +190,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
} }
newVersion.OID = *id newVersion.OID = *id
if err = n.treeService.AddVersion(ctx, &p.BktInfo.CID, newVersion); err != nil { if err = n.treeService.AddVersion(ctx, p.BktInfo.CID, newVersion); err != nil {
return nil, fmt.Errorf("couldn't add new verion to tree service: %w", err) return nil, fmt.Errorf("couldn't add new verion to tree service: %w", err)
} }
@ -243,7 +243,7 @@ func (n *layer) headLastVersionIfNotDeleted(ctx context.Context, bkt *data.Bucke
} }
} }
node, err := n.treeService.GetLatestVersion(ctx, &bkt.CID, objectName) node, err := n.treeService.GetLatestVersion(ctx, bkt.CID, objectName)
if err != nil { if err != nil {
if errors.Is(err, ErrNodeNotFound) { if errors.Is(err, ErrNodeNotFound) {
return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchKey) return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchKey)
@ -279,7 +279,7 @@ func (n *layer) headVersion(ctx context.Context, bkt *data.BucketInfo, p *HeadOb
var err error var err error
var foundVersion *data.NodeVersion var foundVersion *data.NodeVersion
if p.VersionID == UnversionedObjectVersionID { if p.VersionID == UnversionedObjectVersionID {
foundVersion, err = n.treeService.GetUnversioned(ctx, &bkt.CID, p.Object) foundVersion, err = n.treeService.GetUnversioned(ctx, bkt.CID, p.Object)
if err != nil { if err != nil {
if errors.Is(err, ErrNodeNotFound) { if errors.Is(err, ErrNodeNotFound) {
return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchVersion) return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchVersion)
@ -287,7 +287,7 @@ func (n *layer) headVersion(ctx context.Context, bkt *data.BucketInfo, p *HeadOb
return nil, err return nil, err
} }
} else { } else {
versions, err := n.treeService.GetVersions(ctx, &bkt.CID, p.Object) versions, err := n.treeService.GetVersions(ctx, bkt.CID, p.Object)
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't get versions: %w", err) return nil, fmt.Errorf("couldn't get versions: %w", err)
} }
@ -422,11 +422,11 @@ func (n *layer) getLatestObjectsVersions(ctx context.Context, p allObjectParams)
return nil, nil, nil return nil, nil, nil
} }
cacheKey := cache.CreateObjectsListCacheKey(&p.Bucket.CID, p.Prefix, true) cacheKey := cache.CreateObjectsListCacheKey(p.Bucket.CID, p.Prefix, true)
nodeVersions := n.listsCache.GetVersions(cacheKey) nodeVersions := n.listsCache.GetVersions(cacheKey)
if nodeVersions == nil { if nodeVersions == nil {
nodeVersions, err = n.treeService.GetLatestVersionsByPrefix(ctx, &p.Bucket.CID, p.Prefix) nodeVersions, err = n.treeService.GetLatestVersionsByPrefix(ctx, p.Bucket.CID, p.Prefix)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -538,11 +538,11 @@ func (n *layer) initWorkerPool(ctx context.Context, size int, p allObjectParams,
func (n *layer) getAllObjectsVersions(ctx context.Context, bkt *data.BucketInfo, prefix, delimiter string) (map[string][]*data.ExtendedObjectInfo, error) { func (n *layer) getAllObjectsVersions(ctx context.Context, bkt *data.BucketInfo, prefix, delimiter string) (map[string][]*data.ExtendedObjectInfo, error) {
var err error var err error
cacheKey := cache.CreateObjectsListCacheKey(&bkt.CID, prefix, false) cacheKey := cache.CreateObjectsListCacheKey(bkt.CID, prefix, false)
nodeVersions := n.listsCache.GetVersions(cacheKey) nodeVersions := n.listsCache.GetVersions(cacheKey)
if nodeVersions == nil { if nodeVersions == nil {
nodeVersions, err = n.treeService.GetAllVersionsByPrefix(ctx, &bkt.CID, prefix) nodeVersions, err = n.treeService.GetAllVersionsByPrefix(ctx, bkt.CID, prefix)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -26,7 +26,7 @@ func (n *layer) PutLockInfo(ctx context.Context, objVersion *ObjectVersion, newL
return err return err
} }
lockInfo, err := n.treeService.GetLock(ctx, &cnrID, versionNode.ID) lockInfo, err := n.treeService.GetLock(ctx, cnrID, versionNode.ID)
if err != nil && !errorsStd.Is(err, ErrNodeNotFound) { if err != nil && !errorsStd.Is(err, ErrNodeNotFound) {
return err return err
} }
@ -76,7 +76,7 @@ func (n *layer) PutLockInfo(ctx context.Context, objVersion *ObjectVersion, newL
} }
} }
if err = n.treeService.PutLock(ctx, &cnrID, versionNode.ID, lockInfo); err != nil { if err = n.treeService.PutLock(ctx, cnrID, versionNode.ID, lockInfo); err != nil {
return fmt.Errorf("couldn't put lock into tree: %w", err) return fmt.Errorf("couldn't put lock into tree: %w", err)
} }
@ -114,7 +114,7 @@ func (n *layer) GetLockInfo(ctx context.Context, objVersion *ObjectVersion) (*da
return nil, err return nil, err
} }
lockInfo, err := n.treeService.GetLock(ctx, &objVersion.BktInfo.CID, versionNode.ID) lockInfo, err := n.treeService.GetLock(ctx, objVersion.BktInfo.CID, versionNode.ID)
if err != nil && !errorsStd.Is(err, ErrNodeNotFound) { if err != nil && !errorsStd.Is(err, ErrNodeNotFound) {
return nil, err return nil, err
} }
@ -133,7 +133,7 @@ func (n *layer) getCORS(ctx context.Context, bkt *data.BucketInfo, sysName strin
if cors := n.systemCache.GetCORS(systemObjectKey(bkt, sysName)); cors != nil { if cors := n.systemCache.GetCORS(systemObjectKey(bkt, sysName)); cors != nil {
return cors, nil return cors, nil
} }
objID, err := n.treeService.GetBucketCORS(ctx, &bkt.CID) objID, err := n.treeService.GetBucketCORS(ctx, bkt.CID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -157,7 +157,7 @@ func (n *layer) getCORS(ctx context.Context, bkt *data.BucketInfo, sysName strin
objID, _ := obj.ID() objID, _ := obj.ID()
n.log.Warn("couldn't put system meta to objects cache", n.log.Warn("couldn't put system meta to objects cache",
zap.Stringer("object id", &objID), zap.Stringer("object id", &objID),
zap.Stringer("bucket id", bkt.CID), zap.String("bucket id", bkt.CID.EncodeToString()),
zap.Error(err)) zap.Error(err))
} }
@ -180,7 +180,7 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo)
return settings, nil return settings, nil
} }
settings, err := n.treeService.GetSettingsNode(ctx, &bktInfo.CID) settings, err := n.treeService.GetSettingsNode(ctx, bktInfo.CID)
if err != nil { if err != nil {
if !errorsStd.Is(err, ErrNodeNotFound) { if !errorsStd.Is(err, ErrNodeNotFound) {
return nil, err return nil, err
@ -191,7 +191,7 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo)
if err = n.systemCache.PutSettings(systemKey, settings); err != nil { if err = n.systemCache.PutSettings(systemKey, settings); err != nil {
n.log.Warn("couldn't put system meta to objects cache", n.log.Warn("couldn't put system meta to objects cache",
zap.Stringer("bucket id", bktInfo.CID), zap.String("bucket id", bktInfo.CID.EncodeToString()),
zap.Error(err)) zap.Error(err))
} }
@ -199,7 +199,7 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo)
} }
func (n *layer) PutBucketSettings(ctx context.Context, p *PutSettingsParams) error { func (n *layer) PutBucketSettings(ctx context.Context, p *PutSettingsParams) error {
if err := n.treeService.PutSettingsNode(ctx, &p.BktInfo.CID, p.Settings); err != nil { if err := n.treeService.PutSettingsNode(ctx, p.BktInfo.CID, p.Settings); err != nil {
return fmt.Errorf("failed to get settings node: %w", err) return fmt.Errorf("failed to get settings node: %w", err)
} }

View file

@ -27,7 +27,7 @@ func (n *layer) GetObjectTagging(ctx context.Context, p *ObjectVersion) (string,
} }
p.VersionID = version.OID.EncodeToString() p.VersionID = version.OID.EncodeToString()
tags, err = n.treeService.GetObjectTagging(ctx, &p.BktInfo.CID, version) tags, err = n.treeService.GetObjectTagging(ctx, p.BktInfo.CID, version)
if err != nil { if err != nil {
if errorsStd.Is(err, ErrNodeNotFound) { if errorsStd.Is(err, ErrNodeNotFound) {
return "", nil, errors.GetAPIError(errors.ErrNoSuchKey) return "", nil, errors.GetAPIError(errors.ErrNoSuchKey)
@ -49,7 +49,7 @@ func (n *layer) PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet m
} }
p.VersionID = version.OID.EncodeToString() p.VersionID = version.OID.EncodeToString()
err = n.treeService.PutObjectTagging(ctx, &p.BktInfo.CID, version, tagSet) err = n.treeService.PutObjectTagging(ctx, p.BktInfo.CID, version, tagSet)
if err != nil { if err != nil {
if errorsStd.Is(err, ErrNodeNotFound) { if errorsStd.Is(err, ErrNodeNotFound) {
return errors.GetAPIError(errors.ErrNoSuchKey) return errors.GetAPIError(errors.ErrNoSuchKey)
@ -70,7 +70,7 @@ func (n *layer) DeleteObjectTagging(ctx context.Context, p *ObjectVersion) error
return err return err
} }
err = n.treeService.DeleteObjectTagging(ctx, &p.BktInfo.CID, version) err = n.treeService.DeleteObjectTagging(ctx, p.BktInfo.CID, version)
if err != nil { if err != nil {
if errorsStd.Is(err, ErrNodeNotFound) { if errorsStd.Is(err, ErrNodeNotFound) {
return errors.GetAPIError(errors.ErrNoSuchKey) return errors.GetAPIError(errors.ErrNoSuchKey)
@ -83,7 +83,7 @@ func (n *layer) DeleteObjectTagging(ctx context.Context, p *ObjectVersion) error
return nil return nil
} }
func (n *layer) GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string]string, error) { func (n *layer) GetBucketTagging(ctx context.Context, cnrID cid.ID) (map[string]string, error) {
var ( var (
err error err error
tags map[string]string tags map[string]string
@ -105,7 +105,7 @@ func (n *layer) GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string
return tags, nil return tags, nil
} }
func (n *layer) PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error { func (n *layer) PutBucketTagging(ctx context.Context, cnrID cid.ID, tagSet map[string]string) error {
if err := n.treeService.PutBucketTagging(ctx, cnrID, tagSet); err != nil { if err := n.treeService.PutBucketTagging(ctx, cnrID, tagSet); err != nil {
return err return err
} }
@ -116,7 +116,7 @@ func (n *layer) PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[
return nil return nil
} }
func (n *layer) DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error { func (n *layer) DeleteBucketTagging(ctx context.Context, cnrID cid.ID) error {
n.systemCache.Delete(bucketTaggingCacheKey(cnrID)) n.systemCache.Delete(bucketTaggingCacheKey(cnrID))
return n.treeService.DeleteBucketTagging(ctx, cnrID) return n.treeService.DeleteBucketTagging(ctx, cnrID)
@ -126,7 +126,7 @@ func objectTaggingCacheKey(p *ObjectVersion) string {
return ".tagset." + p.BktInfo.CID.EncodeToString() + "." + p.ObjectName + "." + p.VersionID return ".tagset." + p.BktInfo.CID.EncodeToString() + "." + p.ObjectName + "." + p.VersionID
} }
func bucketTaggingCacheKey(cnrID *cid.ID) string { func bucketTaggingCacheKey(cnrID cid.ID) string {
return ".tagset." + cnrID.EncodeToString() return ".tagset." + cnrID.EncodeToString()
} }
@ -135,11 +135,11 @@ func (n *layer) getNodeVersion(ctx context.Context, objVersion *ObjectVersion) (
var version *data.NodeVersion var version *data.NodeVersion
if objVersion.VersionID == UnversionedObjectVersionID { if objVersion.VersionID == UnversionedObjectVersionID {
version, err = n.treeService.GetUnversioned(ctx, &objVersion.BktInfo.CID, objVersion.ObjectName) version, err = n.treeService.GetUnversioned(ctx, objVersion.BktInfo.CID, objVersion.ObjectName)
} else if len(objVersion.VersionID) == 0 { } else if len(objVersion.VersionID) == 0 {
version, err = n.treeService.GetLatestVersion(ctx, &objVersion.BktInfo.CID, objVersion.ObjectName) version, err = n.treeService.GetLatestVersion(ctx, objVersion.BktInfo.CID, objVersion.ObjectName)
} else { } else {
versions, err2 := n.treeService.GetVersions(ctx, &objVersion.BktInfo.CID, objVersion.ObjectName) versions, err2 := n.treeService.GetVersions(ctx, objVersion.BktInfo.CID, objVersion.ObjectName)
if err2 != nil { if err2 != nil {
return nil, err2 return nil, err2
} }

View file

@ -20,38 +20,38 @@ type TreeServiceMock struct {
parts map[string]map[int]*data.PartInfo parts map[string]map[int]*data.PartInfo
} }
func (t *TreeServiceMock) GetObjectTaggingAndLock(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error) { func (t *TreeServiceMock) GetObjectTaggingAndLock(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error) {
// TODO implement object tagging // TODO implement object tagging
lock, err := t.GetLock(ctx, cnrID, objVersion.ID) lock, err := t.GetLock(ctx, cnrID, objVersion.ID)
return nil, lock, err return nil, lock, err
} }
func (t *TreeServiceMock) GetObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, error) { func (t *TreeServiceMock) GetObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, error) {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) PutObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error { func (t *TreeServiceMock) PutObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) DeleteObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) error { func (t *TreeServiceMock) DeleteObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) error {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string]string, error) { func (t *TreeServiceMock) GetBucketTagging(ctx context.Context, cnrID cid.ID) (map[string]string, error) {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error { func (t *TreeServiceMock) PutBucketTagging(ctx context.Context, cnrID cid.ID, tagSet map[string]string) error {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error { func (t *TreeServiceMock) DeleteBucketTagging(ctx context.Context, cnrID cid.ID) error {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
@ -67,12 +67,12 @@ func NewTreeService() *TreeServiceMock {
} }
} }
func (t *TreeServiceMock) PutSettingsNode(_ context.Context, id *cid.ID, settings *data.BucketSettings) error { func (t *TreeServiceMock) PutSettingsNode(_ context.Context, id cid.ID, settings *data.BucketSettings) error {
t.settings[id.EncodeToString()] = settings t.settings[id.EncodeToString()] = settings
return nil return nil
} }
func (t *TreeServiceMock) GetSettingsNode(_ context.Context, id *cid.ID) (*data.BucketSettings, error) { func (t *TreeServiceMock) GetSettingsNode(_ context.Context, id cid.ID) (*data.BucketSettings, error) {
settings, ok := t.settings[id.EncodeToString()] settings, ok := t.settings[id.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -81,27 +81,27 @@ func (t *TreeServiceMock) GetSettingsNode(_ context.Context, id *cid.ID) (*data.
return settings, nil return settings, nil
} }
func (t *TreeServiceMock) GetNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (t *TreeServiceMock) GetNotificationConfigurationNode(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) PutNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) { func (t *TreeServiceMock) PutNotificationConfigurationNode(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) GetBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (t *TreeServiceMock) GetBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) PutBucketCORS(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) { func (t *TreeServiceMock) PutBucketCORS(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) DeleteBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (t *TreeServiceMock) DeleteBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) GetVersions(_ context.Context, cnrID *cid.ID, objectName string) ([]*data.NodeVersion, error) { func (t *TreeServiceMock) GetVersions(_ context.Context, cnrID cid.ID, objectName string) ([]*data.NodeVersion, error) {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -115,7 +115,7 @@ func (t *TreeServiceMock) GetVersions(_ context.Context, cnrID *cid.ID, objectNa
return versions, nil return versions, nil
} }
func (t *TreeServiceMock) GetLatestVersion(_ context.Context, cnrID *cid.ID, objectName string) (*data.NodeVersion, error) { func (t *TreeServiceMock) GetLatestVersion(_ context.Context, cnrID cid.ID, objectName string) (*data.NodeVersion, error) {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -137,7 +137,7 @@ func (t *TreeServiceMock) GetLatestVersion(_ context.Context, cnrID *cid.ID, obj
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
} }
func (t *TreeServiceMock) GetLatestVersionsByPrefix(_ context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) { func (t *TreeServiceMock) GetLatestVersionsByPrefix(_ context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error) {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -162,7 +162,7 @@ func (t *TreeServiceMock) GetLatestVersionsByPrefix(_ context.Context, cnrID *ci
return result, nil return result, nil
} }
func (t *TreeServiceMock) GetUnversioned(_ context.Context, cnrID *cid.ID, objectName string) (*data.NodeVersion, error) { func (t *TreeServiceMock) GetUnversioned(_ context.Context, cnrID cid.ID, objectName string) (*data.NodeVersion, error) {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -182,7 +182,7 @@ func (t *TreeServiceMock) GetUnversioned(_ context.Context, cnrID *cid.ID, objec
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
} }
func (t *TreeServiceMock) AddVersion(_ context.Context, cnrID *cid.ID, newVersion *data.NodeVersion) error { func (t *TreeServiceMock) AddVersion(_ context.Context, cnrID cid.ID, newVersion *data.NodeVersion) error {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
t.versions[cnrID.EncodeToString()] = map[string][]*data.NodeVersion{ t.versions[cnrID.EncodeToString()] = map[string][]*data.NodeVersion{
@ -222,7 +222,7 @@ func (t *TreeServiceMock) AddVersion(_ context.Context, cnrID *cid.ID, newVersio
return nil return nil
} }
func (t *TreeServiceMock) RemoveVersion(_ context.Context, cnrID *cid.ID, nodeID uint64) error { func (t *TreeServiceMock) RemoveVersion(_ context.Context, cnrID cid.ID, nodeID uint64) error {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return ErrNodeNotFound return ErrNodeNotFound
@ -240,7 +240,7 @@ func (t *TreeServiceMock) RemoveVersion(_ context.Context, cnrID *cid.ID, nodeID
return ErrNodeNotFound return ErrNodeNotFound
} }
func (t *TreeServiceMock) GetAllVersionsByPrefix(_ context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) { func (t *TreeServiceMock) GetAllVersionsByPrefix(_ context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error) {
cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()] cnrVersionsMap, ok := t.versions[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, nil return nil, nil
@ -256,7 +256,7 @@ func (t *TreeServiceMock) GetAllVersionsByPrefix(_ context.Context, cnrID *cid.I
return result, nil return result, nil
} }
func (t *TreeServiceMock) CreateMultipartUpload(_ context.Context, cnrID *cid.ID, info *data.MultipartInfo) error { func (t *TreeServiceMock) CreateMultipartUpload(_ context.Context, cnrID cid.ID, info *data.MultipartInfo) error {
cnrMultipartsMap, ok := t.multiparts[cnrID.EncodeToString()] cnrMultipartsMap, ok := t.multiparts[cnrID.EncodeToString()]
if !ok { if !ok {
t.multiparts[cnrID.EncodeToString()] = map[string][]*data.MultipartInfo{ t.multiparts[cnrID.EncodeToString()] = map[string][]*data.MultipartInfo{
@ -274,11 +274,11 @@ func (t *TreeServiceMock) CreateMultipartUpload(_ context.Context, cnrID *cid.ID
return nil return nil
} }
func (t *TreeServiceMock) GetMultipartUploadsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.MultipartInfo, error) { func (t *TreeServiceMock) GetMultipartUploadsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.MultipartInfo, error) {
panic("implement me") panic("implement me")
} }
func (t *TreeServiceMock) GetMultipartUpload(_ context.Context, cnrID *cid.ID, objectName, uploadID string) (*data.MultipartInfo, error) { func (t *TreeServiceMock) GetMultipartUpload(_ context.Context, cnrID cid.ID, objectName, uploadID string) (*data.MultipartInfo, error) {
cnrMultipartsMap, ok := t.multiparts[cnrID.EncodeToString()] cnrMultipartsMap, ok := t.multiparts[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
@ -294,7 +294,7 @@ func (t *TreeServiceMock) GetMultipartUpload(_ context.Context, cnrID *cid.ID, o
return nil, ErrNodeNotFound return nil, ErrNodeNotFound
} }
func (t *TreeServiceMock) AddPart(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error) { func (t *TreeServiceMock) AddPart(ctx context.Context, cnrID cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error) {
multipartInfo, err := t.GetMultipartUpload(ctx, cnrID, info.Key, info.UploadID) multipartInfo, err := t.GetMultipartUpload(ctx, cnrID, info.Key, info.UploadID)
if err != nil { if err != nil {
return nil, err return nil, err
@ -315,7 +315,7 @@ func (t *TreeServiceMock) AddPart(ctx context.Context, cnrID *cid.ID, multipartN
return nil, nil return nil, nil
} }
func (t *TreeServiceMock) GetParts(_ context.Context, cnrID *cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error) { func (t *TreeServiceMock) GetParts(_ context.Context, cnrID cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error) {
cnrMultipartsMap := t.multiparts[cnrID.EncodeToString()] cnrMultipartsMap := t.multiparts[cnrID.EncodeToString()]
var foundMultipart *data.MultipartInfo var foundMultipart *data.MultipartInfo
@ -343,7 +343,7 @@ LOOP:
return result, nil return result, nil
} }
func (t *TreeServiceMock) DeleteMultipartUpload(_ context.Context, cnrID *cid.ID, multipartNodeID uint64) error { func (t *TreeServiceMock) DeleteMultipartUpload(_ context.Context, cnrID cid.ID, multipartNodeID uint64) error {
cnrMultipartsMap := t.multiparts[cnrID.EncodeToString()] cnrMultipartsMap := t.multiparts[cnrID.EncodeToString()]
var uploadID string var uploadID string
@ -367,7 +367,7 @@ LOOP:
return nil return nil
} }
func (t *TreeServiceMock) PutLock(ctx context.Context, cnrID *cid.ID, nodeID uint64, lock *data.LockInfo) error { func (t *TreeServiceMock) PutLock(ctx context.Context, cnrID cid.ID, nodeID uint64, lock *data.LockInfo) error {
cnrLockMap, ok := t.locks[cnrID.EncodeToString()] cnrLockMap, ok := t.locks[cnrID.EncodeToString()]
if !ok { if !ok {
t.locks[cnrID.EncodeToString()] = map[uint64]*data.LockInfo{ t.locks[cnrID.EncodeToString()] = map[uint64]*data.LockInfo{
@ -381,7 +381,7 @@ func (t *TreeServiceMock) PutLock(ctx context.Context, cnrID *cid.ID, nodeID uin
return nil return nil
} }
func (t *TreeServiceMock) GetLock(ctx context.Context, cnrID *cid.ID, nodeID uint64) (*data.LockInfo, error) { func (t *TreeServiceMock) GetLock(ctx context.Context, cnrID cid.ID, nodeID uint64) (*data.LockInfo, error) {
cnrLockMap, ok := t.locks[cnrID.EncodeToString()] cnrLockMap, ok := t.locks[cnrID.EncodeToString()]
if !ok { if !ok {
return nil, nil return nil, nil

View file

@ -12,58 +12,58 @@ import (
// TreeService provide interface to interact with tree service using s3 data models. // TreeService provide interface to interact with tree service using s3 data models.
type TreeService interface { type TreeService interface {
// PutSettingsNode update or create new settings node in tree service. // PutSettingsNode update or create new settings node in tree service.
PutSettingsNode(context.Context, *cid.ID, *data.BucketSettings) error PutSettingsNode(context.Context, cid.ID, *data.BucketSettings) error
// GetSettingsNode retrieves the settings node from the tree service and form data.BucketSettings. // GetSettingsNode retrieves the settings node from the tree service and form data.BucketSettings.
// //
// If node is not found returns ErrNodeNotFound error. // If node is not found returns ErrNodeNotFound error.
GetSettingsNode(context.Context, *cid.ID) (*data.BucketSettings, error) GetSettingsNode(context.Context, cid.ID) (*data.BucketSettings, error)
GetNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) GetNotificationConfigurationNode(ctx context.Context, cnrID cid.ID) (*oid.ID, error)
// PutNotificationConfigurationNode puts a node to a system tree // PutNotificationConfigurationNode puts a node to a system tree
// and returns objectID of a previous notif config which must be deleted in NeoFS // and returns objectID of a previous notif config which must be deleted in NeoFS
PutNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) PutNotificationConfigurationNode(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error)
GetBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) GetBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error)
// PutBucketCORS puts a node to a system tree and returns objectID of a previous cors config which must be deleted in NeoFS // PutBucketCORS puts a node to a system tree and returns objectID of a previous cors config which must be deleted in NeoFS
PutBucketCORS(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) PutBucketCORS(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error)
// DeleteBucketCORS removes a node from a system tree and returns objID which must be deleted in NeoFS // DeleteBucketCORS removes a node from a system tree and returns objID which must be deleted in NeoFS
DeleteBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) DeleteBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error)
GetObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, error) GetObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, error)
PutObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error PutObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error
DeleteObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) error DeleteObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) error
GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string]string, error) GetBucketTagging(ctx context.Context, cnrID cid.ID) (map[string]string, error)
PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error PutBucketTagging(ctx context.Context, cnrID cid.ID, tagSet map[string]string) error
DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error DeleteBucketTagging(ctx context.Context, cnrID cid.ID) error
GetVersions(ctx context.Context, cnrID *cid.ID, objectName string) ([]*data.NodeVersion, error) GetVersions(ctx context.Context, cnrID cid.ID, objectName string) ([]*data.NodeVersion, error)
GetLatestVersion(ctx context.Context, cnrID *cid.ID, objectName string) (*data.NodeVersion, error) GetLatestVersion(ctx context.Context, cnrID cid.ID, objectName string) (*data.NodeVersion, error)
GetLatestVersionsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) GetLatestVersionsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error)
GetAllVersionsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) GetAllVersionsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error)
GetUnversioned(ctx context.Context, cnrID *cid.ID, objectName string) (*data.NodeVersion, error) GetUnversioned(ctx context.Context, cnrID cid.ID, objectName string) (*data.NodeVersion, error)
AddVersion(ctx context.Context, cnrID *cid.ID, newVersion *data.NodeVersion) error AddVersion(ctx context.Context, cnrID cid.ID, newVersion *data.NodeVersion) error
RemoveVersion(ctx context.Context, cnrID *cid.ID, nodeID uint64) error RemoveVersion(ctx context.Context, cnrID cid.ID, nodeID uint64) error
PutLock(ctx context.Context, cnrID *cid.ID, nodeID uint64, lock *data.LockInfo) error PutLock(ctx context.Context, cnrID cid.ID, nodeID uint64, lock *data.LockInfo) error
GetLock(ctx context.Context, cnrID *cid.ID, nodeID uint64) (*data.LockInfo, error) GetLock(ctx context.Context, cnrID cid.ID, nodeID uint64) (*data.LockInfo, error)
CreateMultipartUpload(ctx context.Context, cnrID *cid.ID, info *data.MultipartInfo) error CreateMultipartUpload(ctx context.Context, cnrID cid.ID, info *data.MultipartInfo) error
DeleteMultipartUpload(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64) error DeleteMultipartUpload(ctx context.Context, cnrID cid.ID, multipartNodeID uint64) error
GetMultipartUploadsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.MultipartInfo, error) GetMultipartUploadsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.MultipartInfo, error)
GetMultipartUpload(ctx context.Context, cnrID *cid.ID, objectName, uploadID string) (*data.MultipartInfo, error) GetMultipartUpload(ctx context.Context, cnrID cid.ID, objectName, uploadID string) (*data.MultipartInfo, error)
// AddPart puts a node to a system tree as a child of appropriate multipart upload // AddPart puts a node to a system tree as a child of appropriate multipart upload
// and returns objectID of a previous part which must be deleted in NeoFS. // and returns objectID of a previous part which must be deleted in NeoFS.
// If a part is being added for the first time, the previous part ID will be nil. // If a part is being added for the first time, the previous part ID will be nil.
AddPart(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error) AddPart(ctx context.Context, cnrID cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error)
GetParts(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error) GetParts(ctx context.Context, cnrID cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error)
// Compound methods for optimizations // Compound methods for optimizations
// GetObjectTaggingAndLock unifies GetObjectTagging and GetLock methods in single tree service invocation. // GetObjectTaggingAndLock unifies GetObjectTagging and GetLock methods in single tree service invocation.
GetObjectTaggingAndLock(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error) GetObjectTaggingAndLock(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error)
} }
// ErrNodeNotFound is returned from Tree service in case of not found error. // ErrNodeNotFound is returned from Tree service in case of not found error.

View file

@ -171,7 +171,7 @@ func prepareContext(t *testing.T, cachesConfig ...*CachesConfig) *testContext {
bktInfo: &data.BucketInfo{ bktInfo: &data.BucketInfo{
Name: bktName, Name: bktName,
Owner: *usertest.ID(), Owner: *usertest.ID(),
CID: *bktID, CID: bktID,
}, },
obj: "obj1", obj: "obj1",
t: t, t: t,

View file

@ -29,22 +29,22 @@ type Config struct {
type BucketResolver struct { type BucketResolver struct {
Name string Name string
resolve func(context.Context, string) (*cid.ID, error) resolve func(context.Context, string) (cid.ID, error)
next *BucketResolver next *BucketResolver
} }
func (r *BucketResolver) SetResolveFunc(fn func(context.Context, string) (*cid.ID, error)) { func (r *BucketResolver) SetResolveFunc(fn func(context.Context, string) (cid.ID, error)) {
r.resolve = fn r.resolve = fn
} }
func (r *BucketResolver) Resolve(ctx context.Context, name string) (*cid.ID, error) { func (r *BucketResolver) Resolve(ctx context.Context, name string) (cid.ID, error) {
cnrID, err := r.resolve(ctx, name) cnrID, err := r.resolve(ctx, name)
if err != nil { if err != nil {
if r.next != nil { if r.next != nil {
return r.next.Resolve(ctx, name) return r.next.Resolve(ctx, name)
} }
return nil, fmt.Errorf("failed resolve: %w", err) return cid.ID{}, fmt.Errorf("failed resolve: %w", err)
} }
return cnrID, nil return cnrID, nil
} }
@ -90,18 +90,18 @@ func NewDNSResolver(neoFS NeoFS, next *BucketResolver) (*BucketResolver, error)
var dns ns.DNS var dns ns.DNS
resolveFunc := func(ctx context.Context, name string) (*cid.ID, error) { resolveFunc := func(ctx context.Context, name string) (cid.ID, error) {
domain, err := neoFS.SystemDNS(ctx) domain, err := neoFS.SystemDNS(ctx)
if err != nil { if err != nil {
return nil, fmt.Errorf("read system DNS parameter of the NeoFS: %w", err) return cid.ID{}, fmt.Errorf("read system DNS parameter of the NeoFS: %w", err)
} }
domain = name + "." + domain domain = name + "." + domain
cnrID, err := dns.ResolveContainerName(domain) cnrID, err := dns.ResolveContainerName(domain)
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't resolve container '%s' as '%s': %w", name, domain, err) return cid.ID{}, fmt.Errorf("couldn't resolve container '%s' as '%s': %w", name, domain, err)
} }
return &cnrID, nil return cnrID, nil
} }
return &BucketResolver{ return &BucketResolver{
@ -123,12 +123,12 @@ func NewNNSResolver(address string, next *BucketResolver) (*BucketResolver, erro
return nil, fmt.Errorf("dial %s: %w", address, err) return nil, fmt.Errorf("dial %s: %w", address, err)
} }
resolveFunc := func(_ context.Context, name string) (*cid.ID, error) { resolveFunc := func(_ context.Context, name string) (cid.ID, error) {
cnrID, err := nns.ResolveContainerName(name) cnrID, err := nns.ResolveContainerName(name)
if err != nil { if err != nil {
return nil, fmt.Errorf("couldn't resolve container '%s': %w", name, err) return cid.ID{}, fmt.Errorf("couldn't resolve container '%s': %w", name, err)
} }
return &cnrID, nil return cnrID, nil
} }
return &BucketResolver{ return &BucketResolver{

View file

@ -67,7 +67,7 @@ type NeoFS interface {
// //
// It returns exactly one non-nil value. It returns any error encountered which // It returns exactly one non-nil value. It returns any error encountered which
// prevented the container from being created. // prevented the container from being created.
CreateContainer(context.Context, PrmContainerCreate) (*cid.ID, error) CreateContainer(context.Context, PrmContainerCreate) (cid.ID, error)
// TimeToEpoch computes the current epoch and the epoch that corresponds to the provided time. // TimeToEpoch computes the current epoch and the epoch that corresponds to the provided time.
// Note: // Note:
@ -108,7 +108,7 @@ type (
// ContainerOptions groups parameters of auth container to put the secret into. // ContainerOptions groups parameters of auth container to put the secret into.
ContainerOptions struct { ContainerOptions struct {
ID *cid.ID ID cid.ID
FriendlyName string FriendlyName string
PlacementPolicy string PlacementPolicy string
} }
@ -141,17 +141,16 @@ type (
} }
) )
func (a *Agent) checkContainer(ctx context.Context, opts ContainerOptions, idOwner user.ID) (*cid.ID, error) { func (a *Agent) checkContainer(ctx context.Context, opts ContainerOptions, idOwner user.ID) (cid.ID, error) {
if opts.ID != nil { if !opts.ID.Equals(cid.ID{}) {
// check that the container exists return opts.ID, a.neoFS.ContainerExists(ctx, opts.ID)
return opts.ID, a.neoFS.ContainerExists(ctx, *opts.ID)
} }
var prm PrmContainerCreate var prm PrmContainerCreate
err := prm.Policy.DecodeString(opts.PlacementPolicy) err := prm.Policy.DecodeString(opts.PlacementPolicy)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to build placement policy: %w", err) return cid.ID{}, fmt.Errorf("failed to build placement policy: %w", err)
} }
prm.Owner = idOwner prm.Owner = idOwner
@ -159,7 +158,7 @@ func (a *Agent) checkContainer(ctx context.Context, opts ContainerOptions, idOwn
cnrID, err := a.neoFS.CreateContainer(ctx, prm) cnrID, err := a.neoFS.CreateContainer(ctx, prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("create container in NeoFS: %w", err) return cid.ID{}, fmt.Errorf("create container in NeoFS: %w", err)
} }
return cnrID, nil return cnrID, nil
@ -247,7 +246,7 @@ func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecr
addr, err := tokens. addr, err := tokens.
New(a.neoFS, secrets.EphemeralKey, cache.DefaultAccessBoxConfig(a.log)). New(a.neoFS, secrets.EphemeralKey, cache.DefaultAccessBoxConfig(a.log)).
Put(ctx, *id, idOwner, box, lifetime.Exp, options.GatesPublicKeys...) Put(ctx, id, idOwner, box, lifetime.Exp, options.GatesPublicKeys...)
if err != nil { if err != nil {
return fmt.Errorf("failed to put bearer token: %w", err) return fmt.Errorf("failed to put bearer token: %w", err)
} }
@ -379,9 +378,7 @@ func buildBearerTokens(key *keys.PrivateKey, table *eacl.Table, lifetime lifetim
func buildSessionToken(key *keys.PrivateKey, lifetime lifetimeOptions, ctx sessionTokenContext, gateKey *keys.PublicKey) (*session.Container, error) { func buildSessionToken(key *keys.PrivateKey, lifetime lifetimeOptions, ctx sessionTokenContext, gateKey *keys.PublicKey) (*session.Container, error) {
tok := new(session.Container) tok := new(session.Container)
tok.ForVerb(ctx.verb) tok.ForVerb(ctx.verb)
if ctx.containerID != nil { tok.AppliedTo(ctx.containerID)
tok.AppliedTo(*ctx.containerID)
}
tok.SetID(uuid.New()) tok.SetID(uuid.New())
tok.SetAuthKey((*neofsecdsa.PublicKey)(gateKey)) tok.SetAuthKey((*neofsecdsa.PublicKey)(gateKey))

View file

@ -17,7 +17,7 @@ type (
sessionTokenContext struct { sessionTokenContext struct {
verb session.ContainerVerb verb session.ContainerVerb
containerID *cid.ID containerID cid.ID
} }
) )
@ -40,7 +40,6 @@ func (c *sessionTokenContext) UnmarshalJSON(data []byte) (err error) {
} }
if len(m.ContainerID) > 0 { if len(m.ContainerID) > 0 {
c.containerID = new(cid.ID)
return c.containerID.DecodeString(m.ContainerID) return c.containerID.DecodeString(m.ContainerID)
} }

View file

@ -3,6 +3,7 @@ package authmate
import ( import (
"testing" "testing"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/session" "github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -28,9 +29,9 @@ func TestContainerSessionRules(t *testing.T) {
require.Len(t, sessionContext, 3) require.Len(t, sessionContext, 3)
require.Equal(t, sessionContext[0].verb, session.VerbContainerPut) require.Equal(t, sessionContext[0].verb, session.VerbContainerPut)
require.Nil(t, sessionContext[0].containerID) require.Equal(t, cid.ID{}, sessionContext[0].containerID)
require.Equal(t, sessionContext[1].verb, session.VerbContainerDelete) require.Equal(t, sessionContext[1].verb, session.VerbContainerDelete)
require.NotNil(t, sessionContext[1].containerID) require.NotNil(t, sessionContext[1].containerID)
require.Equal(t, sessionContext[2].verb, session.VerbContainerSetEACL) require.Equal(t, sessionContext[2].verb, session.VerbContainerSetEACL)
require.Nil(t, sessionContext[2].containerID) require.Equal(t, cid.ID{}, sessionContext[2].containerID)
} }

View file

@ -264,9 +264,9 @@ It will be ceil rounded to the nearest amount of epoch.`,
} }
agent := authmate.New(log, neoFS) agent := authmate.New(log, neoFS)
var containerID *cid.ID // keep nil value if container flag is not set
var containerID cid.ID
if len(containerIDFlag) > 0 { if len(containerIDFlag) > 0 {
containerID = new(cid.ID)
if err = containerID.DecodeString(containerIDFlag); err != nil { if err = containerID.DecodeString(containerIDFlag); err != nil {
return cli.Exit(fmt.Sprintf("failed to parse auth container id: %s", err), 3) return cli.Exit(fmt.Sprintf("failed to parse auth container id: %s", err), 3)
} }

View file

@ -106,7 +106,7 @@ var basicACLZero acl.Basic
// CreateContainer implements neofs.NeoFS interface method. // CreateContainer implements neofs.NeoFS interface method.
// //
// If prm.BasicACL is zero, 'eacl-public-read-write' is used. // If prm.BasicACL is zero, 'eacl-public-read-write' is used.
func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreate) (*cid.ID, error) { func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreate) (cid.ID, error) {
if prm.BasicACL == basicACLZero { if prm.BasicACL == basicACLZero {
prm.BasicACL = acl.PublicRWExtended prm.BasicACL = acl.PublicRWExtended
} }
@ -132,7 +132,7 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreat
err := pool.SyncContainerWithNetwork(ctx, &cnr, x.pool) err := pool.SyncContainerWithNetwork(ctx, &cnr, x.pool)
if err != nil { if err != nil {
return nil, fmt.Errorf("sync container with the network state: %w", err) return cid.ID{}, fmt.Errorf("sync container with the network state: %w", err)
} }
var prmPut pool.PrmContainerPut var prmPut pool.PrmContainerPut
@ -146,10 +146,10 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreat
// send request to save the container // send request to save the container
idCnr, err := x.pool.PutContainer(ctx, prmPut) idCnr, err := x.pool.PutContainer(ctx, prmPut)
if err != nil { if err != nil {
return nil, fmt.Errorf("save container via connection pool: %w", err) return cid.ID{}, fmt.Errorf("save container via connection pool: %w", err)
} }
return idCnr, nil return *idCnr, nil
} }
// UserContainers implements neofs.NeoFS interface method. // UserContainers implements neofs.NeoFS interface method.
@ -539,7 +539,7 @@ func (x *AuthmateNeoFS) TimeToEpoch(ctx context.Context, futureTime time.Time) (
} }
// CreateContainer implements authmate.NeoFS interface method. // CreateContainer implements authmate.NeoFS interface method.
func (x *AuthmateNeoFS) CreateContainer(ctx context.Context, prm authmate.PrmContainerCreate) (*cid.ID, error) { func (x *AuthmateNeoFS) CreateContainer(ctx context.Context, prm authmate.PrmContainerCreate) (cid.ID, error) {
basicACL := acl.Private basicACL := acl.Private
// allow reading objects to OTHERS in order to provide read access to S3 gateways // allow reading objects to OTHERS in order to provide read access to S3 gateways
basicACL.AllowOp(acl.OpObjectGet, acl.RoleOthers) basicACL.AllowOp(acl.OpObjectGet, acl.RoleOthers)

View file

@ -37,7 +37,7 @@ type (
} }
getNodesParams struct { getNodesParams struct {
CnrID *cid.ID CnrID cid.ID
TreeID string TreeID string
Path []string Path []string
Meta []string Meta []string
@ -259,7 +259,7 @@ func newPartInfo(node NodeResponse) (*data.PartInfo, error) {
return partInfo, nil return partInfo, nil
} }
func (c *TreeClient) GetSettingsNode(ctx context.Context, cnrID *cid.ID) (*data.BucketSettings, error) { func (c *TreeClient) GetSettingsNode(ctx context.Context, cnrID cid.ID) (*data.BucketSettings, error) {
keysToReturn := []string{versioningEnabledKV, lockConfigurationKV} keysToReturn := []string{versioningEnabledKV, lockConfigurationKV}
node, err := c.getSystemNode(ctx, cnrID, []string{settingsFileName}, keysToReturn) node, err := c.getSystemNode(ctx, cnrID, []string{settingsFileName}, keysToReturn)
if err != nil { if err != nil {
@ -283,7 +283,7 @@ func (c *TreeClient) GetSettingsNode(ctx context.Context, cnrID *cid.ID) (*data.
return settings, nil return settings, nil
} }
func (c *TreeClient) PutSettingsNode(ctx context.Context, cnrID *cid.ID, settings *data.BucketSettings) error { func (c *TreeClient) PutSettingsNode(ctx context.Context, cnrID cid.ID, settings *data.BucketSettings) error {
node, err := c.getSystemNode(ctx, cnrID, []string{settingsFileName}, []string{}) node, err := c.getSystemNode(ctx, cnrID, []string{settingsFileName}, []string{})
isErrNotFound := errors.Is(err, layer.ErrNodeNotFound) isErrNotFound := errors.Is(err, layer.ErrNodeNotFound)
if err != nil && !isErrNotFound { if err != nil && !isErrNotFound {
@ -300,7 +300,7 @@ func (c *TreeClient) PutSettingsNode(ctx context.Context, cnrID *cid.ID, setting
return c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta) return c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta)
} }
func (c *TreeClient) GetNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (c *TreeClient) GetNotificationConfigurationNode(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
node, err := c.getSystemNode(ctx, cnrID, []string{notifConfFileName}, []string{oidKV}) node, err := c.getSystemNode(ctx, cnrID, []string{notifConfFileName}, []string{oidKV})
if err != nil { if err != nil {
return nil, err return nil, err
@ -309,7 +309,7 @@ func (c *TreeClient) GetNotificationConfigurationNode(ctx context.Context, cnrID
return &node.ObjID, nil return &node.ObjID, nil
} }
func (c *TreeClient) PutNotificationConfigurationNode(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) { func (c *TreeClient) PutNotificationConfigurationNode(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error) {
node, err := c.getSystemNode(ctx, cnrID, []string{notifConfFileName}, []string{oidKV}) node, err := c.getSystemNode(ctx, cnrID, []string{notifConfFileName}, []string{oidKV})
isErrNotFound := errors.Is(err, layer.ErrNodeNotFound) isErrNotFound := errors.Is(err, layer.ErrNodeNotFound)
if err != nil && !isErrNotFound { if err != nil && !isErrNotFound {
@ -328,7 +328,7 @@ func (c *TreeClient) PutNotificationConfigurationNode(ctx context.Context, cnrID
return &node.ObjID, c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta) return &node.ObjID, c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta)
} }
func (c *TreeClient) GetBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (c *TreeClient) GetBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV}) node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV})
if err != nil { if err != nil {
return nil, err return nil, err
@ -337,7 +337,7 @@ func (c *TreeClient) GetBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID,
return &node.ObjID, nil return &node.ObjID, nil
} }
func (c *TreeClient) PutBucketCORS(ctx context.Context, cnrID *cid.ID, objID *oid.ID) (*oid.ID, error) { func (c *TreeClient) PutBucketCORS(ctx context.Context, cnrID cid.ID, objID *oid.ID) (*oid.ID, error) {
node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV}) node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV})
isErrNotFound := errors.Is(err, layer.ErrNodeNotFound) isErrNotFound := errors.Is(err, layer.ErrNodeNotFound)
if err != nil && !isErrNotFound { if err != nil && !isErrNotFound {
@ -356,7 +356,7 @@ func (c *TreeClient) PutBucketCORS(ctx context.Context, cnrID *cid.ID, objID *oi
return &node.ObjID, c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta) return &node.ObjID, c.moveNode(ctx, cnrID, systemTree, node.ID, 0, meta)
} }
func (c *TreeClient) DeleteBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.ID, error) { func (c *TreeClient) DeleteBucketCORS(ctx context.Context, cnrID cid.ID) (*oid.ID, error) {
node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV}) node, err := c.getSystemNode(ctx, cnrID, []string{corsFilename}, []string{oidKV})
if err != nil && !errors.Is(err, layer.ErrNodeNotFound) { if err != nil && !errors.Is(err, layer.ErrNodeNotFound) {
return nil, err return nil, err
@ -369,7 +369,7 @@ func (c *TreeClient) DeleteBucketCORS(ctx context.Context, cnrID *cid.ID) (*oid.
return nil, nil return nil, nil
} }
func (c *TreeClient) GetObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, error) { func (c *TreeClient) GetObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, error) {
tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV) tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV)
if err != nil { if err != nil {
return nil, err return nil, err
@ -394,7 +394,7 @@ func getObjectTagging(tagNode *TreeNode) map[string]string {
return meta return meta
} }
func (c *TreeClient) PutObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error { func (c *TreeClient) PutObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion, tagSet map[string]string) error {
tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV) tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV)
if err != nil { if err != nil {
return err return err
@ -416,7 +416,7 @@ func (c *TreeClient) PutObjectTagging(ctx context.Context, cnrID *cid.ID, objVer
return err return err
} }
func (c *TreeClient) DeleteObjectTagging(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) error { func (c *TreeClient) DeleteObjectTagging(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) error {
tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV) tagNode, err := c.getTreeNode(ctx, cnrID, objVersion.ID, isTagKV)
if err != nil { if err != nil {
return err return err
@ -429,7 +429,7 @@ func (c *TreeClient) DeleteObjectTagging(ctx context.Context, cnrID *cid.ID, obj
return c.removeNode(ctx, cnrID, versionTree, tagNode.ID) return c.removeNode(ctx, cnrID, versionTree, tagNode.ID)
} }
func (c *TreeClient) GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[string]string, error) { func (c *TreeClient) GetBucketTagging(ctx context.Context, cnrID cid.ID) (map[string]string, error) {
node, err := c.getSystemNodeWithAllAttributes(ctx, cnrID, []string{bucketTaggingFilename}) node, err := c.getSystemNodeWithAllAttributes(ctx, cnrID, []string{bucketTaggingFilename})
if err != nil { if err != nil {
if strings.Contains(err.Error(), "not found") { if strings.Contains(err.Error(), "not found") {
@ -449,7 +449,7 @@ func (c *TreeClient) GetBucketTagging(ctx context.Context, cnrID *cid.ID) (map[s
return tags, nil return tags, nil
} }
func (c *TreeClient) PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error { func (c *TreeClient) PutBucketTagging(ctx context.Context, cnrID cid.ID, tagSet map[string]string) error {
node, err := c.getSystemNode(ctx, cnrID, []string{bucketTaggingFilename}, []string{}) node, err := c.getSystemNode(ctx, cnrID, []string{bucketTaggingFilename}, []string{})
isErrNotFound := errors.Is(err, layer.ErrNodeNotFound) isErrNotFound := errors.Is(err, layer.ErrNodeNotFound)
if err != nil && !isErrNotFound { if err != nil && !isErrNotFound {
@ -472,7 +472,7 @@ func (c *TreeClient) PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet
return err return err
} }
func (c *TreeClient) DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error { func (c *TreeClient) DeleteBucketTagging(ctx context.Context, cnrID cid.ID) error {
node, err := c.getSystemNode(ctx, cnrID, []string{bucketTaggingFilename}, nil) node, err := c.getSystemNode(ctx, cnrID, []string{bucketTaggingFilename}, nil)
if err != nil && !errors.Is(err, layer.ErrNodeNotFound) { if err != nil && !errors.Is(err, layer.ErrNodeNotFound) {
return err return err
@ -485,7 +485,7 @@ func (c *TreeClient) DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) err
return nil return nil
} }
func (c *TreeClient) getTreeNode(ctx context.Context, cnrID *cid.ID, nodeID uint64, key string) (*TreeNode, error) { func (c *TreeClient) getTreeNode(ctx context.Context, cnrID cid.ID, nodeID uint64, key string) (*TreeNode, error) {
nodes, err := c.getTreeNodes(ctx, cnrID, nodeID, key) nodes, err := c.getTreeNodes(ctx, cnrID, nodeID, key)
if err != nil { if err != nil {
return nil, err return nil, err
@ -495,7 +495,7 @@ func (c *TreeClient) getTreeNode(ctx context.Context, cnrID *cid.ID, nodeID uint
return nodes[key], nil return nodes[key], nil
} }
func (c *TreeClient) getTreeNodes(ctx context.Context, cnrID *cid.ID, nodeID uint64, keys ...string) (map[string]*TreeNode, error) { func (c *TreeClient) getTreeNodes(ctx context.Context, cnrID cid.ID, nodeID uint64, keys ...string) (map[string]*TreeNode, error) {
subtree, err := c.getSubTree(ctx, cnrID, versionTree, nodeID, 1) subtree, err := c.getSubTree(ctx, cnrID, versionTree, nodeID, 1)
if err != nil { if err != nil {
return nil, err return nil, err
@ -522,11 +522,11 @@ func (c *TreeClient) getTreeNodes(ctx context.Context, cnrID *cid.ID, nodeID uin
return treeNodes, nil return treeNodes, nil
} }
func (c *TreeClient) GetVersions(ctx context.Context, cnrID *cid.ID, filepath string) ([]*data.NodeVersion, error) { func (c *TreeClient) GetVersions(ctx context.Context, cnrID cid.ID, filepath string) ([]*data.NodeVersion, error) {
return c.getVersions(ctx, cnrID, versionTree, filepath, false) return c.getVersions(ctx, cnrID, versionTree, filepath, false)
} }
func (c *TreeClient) GetLatestVersion(ctx context.Context, cnrID *cid.ID, objectName string) (*data.NodeVersion, error) { func (c *TreeClient) GetLatestVersion(ctx context.Context, cnrID cid.ID, objectName string) (*data.NodeVersion, error) {
meta := []string{oidKV, isUnversionedKV, isDeleteMarkerKV} meta := []string{oidKV, isUnversionedKV, isDeleteMarkerKV}
path := pathFromName(objectName) path := pathFromName(objectName)
@ -562,7 +562,7 @@ func pathFromName(objectName string) []string {
return path return path
} }
func (c *TreeClient) GetLatestVersionsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) { func (c *TreeClient) GetLatestVersionsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error) {
subTreeNodes, commonPrefix, err := c.getSubTreeByPrefix(ctx, cnrID, versionTree, prefix) subTreeNodes, commonPrefix, err := c.getSubTreeByPrefix(ctx, cnrID, versionTree, prefix)
if err != nil { if err != nil {
return nil, err return nil, err
@ -581,7 +581,7 @@ func (c *TreeClient) GetLatestVersionsByPrefix(ctx context.Context, cnrID *cid.I
return result, nil return result, nil
} }
func (c *TreeClient) determinePrefixNode(ctx context.Context, cnrID *cid.ID, treeID, prefix string) (uint64, string, error) { func (c *TreeClient) determinePrefixNode(ctx context.Context, cnrID cid.ID, treeID, prefix string) (uint64, string, error) {
var rootID uint64 var rootID uint64
path := strings.Split(prefix, separator) path := strings.Split(prefix, separator)
if len(path) > 1 && path[0] == "" { if len(path) > 1 && path[0] == "" {
@ -600,7 +600,7 @@ func (c *TreeClient) determinePrefixNode(ctx context.Context, cnrID *cid.ID, tre
return rootID, tailPrefix, nil return rootID, tailPrefix, nil
} }
func (c *TreeClient) getPrefixNodeID(ctx context.Context, cnrID *cid.ID, treeID string, prefixPath []string) (uint64, error) { func (c *TreeClient) getPrefixNodeID(ctx context.Context, cnrID cid.ID, treeID string, prefixPath []string) (uint64, error) {
p := &getNodesParams{ p := &getNodesParams{
CnrID: cnrID, CnrID: cnrID,
TreeID: treeID, TreeID: treeID,
@ -630,7 +630,7 @@ func (c *TreeClient) getPrefixNodeID(ctx context.Context, cnrID *cid.ID, treeID
return intermediateNodes[0], nil return intermediateNodes[0], nil
} }
func (c *TreeClient) getSubTreeByPrefix(ctx context.Context, cnrID *cid.ID, treeID, prefix string) ([]*tree.GetSubTreeResponse_Body, string, error) { func (c *TreeClient) getSubTreeByPrefix(ctx context.Context, cnrID cid.ID, treeID, prefix string) ([]*tree.GetSubTreeResponse_Body, string, error) {
rootID, tailPrefix, err := c.determinePrefixNode(ctx, cnrID, treeID, prefix) rootID, tailPrefix, err := c.determinePrefixNode(ctx, cnrID, treeID, prefix)
if err != nil { if err != nil {
if errors.Is(err, layer.ErrNodeNotFound) { if errors.Is(err, layer.ErrNodeNotFound) {
@ -675,7 +675,7 @@ func isIntermediate(node *tree.GetNodeByPathResponse_Info) bool {
return node.GetMeta()[0].GetKey() == fileNameKV return node.GetMeta()[0].GetKey() == fileNameKV
} }
func (c *TreeClient) getSubTreeVersions(ctx context.Context, cnrID *cid.ID, nodeID uint64, parentFilePath string, latestOnly bool) ([]*data.NodeVersion, error) { func (c *TreeClient) getSubTreeVersions(ctx context.Context, cnrID cid.ID, nodeID uint64, parentFilePath string, latestOnly bool) ([]*data.NodeVersion, error) {
subTree, err := c.getSubTree(ctx, cnrID, versionTree, nodeID, maxGetSubTreeDepth) subTree, err := c.getSubTree(ctx, cnrID, versionTree, nodeID, maxGetSubTreeDepth)
if err != nil { if err != nil {
return nil, err return nil, err
@ -764,7 +764,7 @@ func formLatestNodeKey(parentID uint64, fileName string) string {
return strconv.FormatUint(parentID, 10) + "." + fileName return strconv.FormatUint(parentID, 10) + "." + fileName
} }
func (c *TreeClient) GetAllVersionsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.NodeVersion, error) { func (c *TreeClient) GetAllVersionsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.NodeVersion, error) {
prefixNodes, headPrefix, err := c.getSubTreeByPrefix(ctx, cnrID, versionTree, prefix) prefixNodes, headPrefix, err := c.getSubTreeByPrefix(ctx, cnrID, versionTree, prefix)
if err != nil { if err != nil {
return nil, err return nil, err
@ -782,11 +782,11 @@ func (c *TreeClient) GetAllVersionsByPrefix(ctx context.Context, cnrID *cid.ID,
return result, nil return result, nil
} }
func (c *TreeClient) GetUnversioned(ctx context.Context, cnrID *cid.ID, filepath string) (*data.NodeVersion, error) { func (c *TreeClient) GetUnversioned(ctx context.Context, cnrID cid.ID, filepath string) (*data.NodeVersion, error) {
return c.getUnversioned(ctx, cnrID, versionTree, filepath) return c.getUnversioned(ctx, cnrID, versionTree, filepath)
} }
func (c *TreeClient) getUnversioned(ctx context.Context, cnrID *cid.ID, treeID, filepath string) (*data.NodeVersion, error) { func (c *TreeClient) getUnversioned(ctx context.Context, cnrID cid.ID, treeID, filepath string) (*data.NodeVersion, error) {
nodes, err := c.getVersions(ctx, cnrID, treeID, filepath, true) nodes, err := c.getVersions(ctx, cnrID, treeID, filepath, true)
if err != nil { if err != nil {
return nil, err return nil, err
@ -803,22 +803,22 @@ func (c *TreeClient) getUnversioned(ctx context.Context, cnrID *cid.ID, treeID,
return nodes[0], nil return nodes[0], nil
} }
func (c *TreeClient) AddVersion(ctx context.Context, cnrID *cid.ID, version *data.NodeVersion) error { func (c *TreeClient) AddVersion(ctx context.Context, cnrID cid.ID, version *data.NodeVersion) error {
return c.addVersion(ctx, cnrID, versionTree, version) return c.addVersion(ctx, cnrID, versionTree, version)
} }
func (c *TreeClient) RemoveVersion(ctx context.Context, cnrID *cid.ID, id uint64) error { func (c *TreeClient) RemoveVersion(ctx context.Context, cnrID cid.ID, id uint64) error {
return c.removeNode(ctx, cnrID, versionTree, id) return c.removeNode(ctx, cnrID, versionTree, id)
} }
func (c *TreeClient) CreateMultipartUpload(ctx context.Context, cnrID *cid.ID, info *data.MultipartInfo) error { func (c *TreeClient) CreateMultipartUpload(ctx context.Context, cnrID cid.ID, info *data.MultipartInfo) error {
path := pathFromName(info.Key) path := pathFromName(info.Key)
meta := metaFromMultipart(info) meta := metaFromMultipart(info)
return c.addNodeByPath(ctx, cnrID, systemTree, path[:len(path)-1], meta) return c.addNodeByPath(ctx, cnrID, systemTree, path[:len(path)-1], meta)
} }
func (c *TreeClient) GetMultipartUploadsByPrefix(ctx context.Context, cnrID *cid.ID, prefix string) ([]*data.MultipartInfo, error) { func (c *TreeClient) GetMultipartUploadsByPrefix(ctx context.Context, cnrID cid.ID, prefix string) ([]*data.MultipartInfo, error) {
subTreeNodes, _, err := c.getSubTreeByPrefix(ctx, cnrID, systemTree, prefix) subTreeNodes, _, err := c.getSubTreeByPrefix(ctx, cnrID, systemTree, prefix)
if err != nil { if err != nil {
return nil, err return nil, err
@ -836,7 +836,7 @@ func (c *TreeClient) GetMultipartUploadsByPrefix(ctx context.Context, cnrID *cid
return result, nil return result, nil
} }
func (c *TreeClient) getSubTreeMultipartUploads(ctx context.Context, cnrID *cid.ID, nodeID uint64) ([]*data.MultipartInfo, error) { func (c *TreeClient) getSubTreeMultipartUploads(ctx context.Context, cnrID cid.ID, nodeID uint64) ([]*data.MultipartInfo, error) {
subTree, err := c.getSubTree(ctx, cnrID, systemTree, nodeID, maxGetSubTreeDepth) subTree, err := c.getSubTree(ctx, cnrID, systemTree, nodeID, maxGetSubTreeDepth)
if err != nil { if err != nil {
return nil, err return nil, err
@ -854,7 +854,7 @@ func (c *TreeClient) getSubTreeMultipartUploads(ctx context.Context, cnrID *cid.
return result, nil return result, nil
} }
func (c *TreeClient) GetMultipartUpload(ctx context.Context, cnrID *cid.ID, objectName, uploadID string) (*data.MultipartInfo, error) { func (c *TreeClient) GetMultipartUpload(ctx context.Context, cnrID cid.ID, objectName, uploadID string) (*data.MultipartInfo, error) {
path := pathFromName(objectName) path := pathFromName(objectName)
p := &getNodesParams{ p := &getNodesParams{
CnrID: cnrID, CnrID: cnrID,
@ -881,7 +881,7 @@ func (c *TreeClient) GetMultipartUpload(ctx context.Context, cnrID *cid.ID, obje
return nil, layer.ErrNodeNotFound return nil, layer.ErrNodeNotFound
} }
func (c *TreeClient) AddPart(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error) { func (c *TreeClient) AddPart(ctx context.Context, cnrID cid.ID, multipartNodeID uint64, info *data.PartInfo) (oldObjIDToDelete *oid.ID, err error) {
parts, err := c.getSubTree(ctx, cnrID, systemTree, multipartNodeID, 1) parts, err := c.getSubTree(ctx, cnrID, systemTree, multipartNodeID, 1)
if err != nil { if err != nil {
return nil, err return nil, err
@ -919,7 +919,7 @@ func (c *TreeClient) AddPart(ctx context.Context, cnrID *cid.ID, multipartNodeID
return oldObjIDToDelete, c.moveNode(ctx, cnrID, systemTree, foundPartID, multipartNodeID, meta) return oldObjIDToDelete, c.moveNode(ctx, cnrID, systemTree, foundPartID, multipartNodeID, meta)
} }
func (c *TreeClient) GetParts(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error) { func (c *TreeClient) GetParts(ctx context.Context, cnrID cid.ID, multipartNodeID uint64) ([]*data.PartInfo, error) {
parts, err := c.getSubTree(ctx, cnrID, systemTree, multipartNodeID, 1) parts, err := c.getSubTree(ctx, cnrID, systemTree, multipartNodeID, 1)
if err != nil { if err != nil {
return nil, err return nil, err
@ -940,11 +940,11 @@ func (c *TreeClient) GetParts(ctx context.Context, cnrID *cid.ID, multipartNodeI
return result, nil return result, nil
} }
func (c *TreeClient) DeleteMultipartUpload(ctx context.Context, cnrID *cid.ID, multipartNodeID uint64) error { func (c *TreeClient) DeleteMultipartUpload(ctx context.Context, cnrID cid.ID, multipartNodeID uint64) error {
return c.removeNode(ctx, cnrID, systemTree, multipartNodeID) return c.removeNode(ctx, cnrID, systemTree, multipartNodeID)
} }
func (c *TreeClient) PutLock(ctx context.Context, cnrID *cid.ID, nodeID uint64, lock *data.LockInfo) error { func (c *TreeClient) PutLock(ctx context.Context, cnrID cid.ID, nodeID uint64, lock *data.LockInfo) error {
meta := map[string]string{isLockKV: "true"} meta := map[string]string{isLockKV: "true"}
if lock.LegalHoldOID != nil { if lock.LegalHoldOID != nil {
@ -966,7 +966,7 @@ func (c *TreeClient) PutLock(ctx context.Context, cnrID *cid.ID, nodeID uint64,
return c.moveNode(ctx, cnrID, versionTree, lock.ID, nodeID, meta) return c.moveNode(ctx, cnrID, versionTree, lock.ID, nodeID, meta)
} }
func (c *TreeClient) GetLock(ctx context.Context, cnrID *cid.ID, nodeID uint64) (*data.LockInfo, error) { func (c *TreeClient) GetLock(ctx context.Context, cnrID cid.ID, nodeID uint64) (*data.LockInfo, error) {
lockNode, err := c.getTreeNode(ctx, cnrID, nodeID, isLockKV) lockNode, err := c.getTreeNode(ctx, cnrID, nodeID, isLockKV)
if err != nil { if err != nil {
return nil, err return nil, err
@ -1004,7 +1004,7 @@ func getLock(lockNode *TreeNode) (*data.LockInfo, error) {
return lockInfo, nil return lockInfo, nil
} }
func (c *TreeClient) GetObjectTaggingAndLock(ctx context.Context, cnrID *cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error) { func (c *TreeClient) GetObjectTaggingAndLock(ctx context.Context, cnrID cid.ID, objVersion *data.NodeVersion) (map[string]string, *data.LockInfo, error) {
nodes, err := c.getTreeNodes(ctx, cnrID, objVersion.ID, isTagKV, isLockKV) nodes, err := c.getTreeNodes(ctx, cnrID, objVersion.ID, isTagKV, isLockKV)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -1026,7 +1026,7 @@ func (c *TreeClient) Close() error {
return nil return nil
} }
func (c *TreeClient) addVersion(ctx context.Context, cnrID *cid.ID, treeID string, version *data.NodeVersion) error { func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string, version *data.NodeVersion) error {
path := pathFromName(version.FilePath) path := pathFromName(version.FilePath)
meta := map[string]string{ meta := map[string]string{
oidKV: version.OID.EncodeToString(), oidKV: version.OID.EncodeToString(),
@ -1060,7 +1060,7 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID *cid.ID, treeID strin
return c.addNodeByPath(ctx, cnrID, treeID, path[:len(path)-1], meta) return c.addNodeByPath(ctx, cnrID, treeID, path[:len(path)-1], meta)
} }
func (c *TreeClient) getVersions(ctx context.Context, cnrID *cid.ID, treeID, filepath string, onlyUnversioned bool) ([]*data.NodeVersion, error) { func (c *TreeClient) getVersions(ctx context.Context, cnrID cid.ID, treeID, filepath string, onlyUnversioned bool) ([]*data.NodeVersion, error) {
keysToReturn := []string{oidKV, isUnversionedKV, isDeleteMarkerKV} keysToReturn := []string{oidKV, isUnversionedKV, isDeleteMarkerKV}
path := pathFromName(filepath) path := pathFromName(filepath)
p := &getNodesParams{ p := &getNodesParams{
@ -1096,7 +1096,7 @@ func (c *TreeClient) getVersions(ctx context.Context, cnrID *cid.ID, treeID, fil
return result, nil return result, nil
} }
func (c *TreeClient) getParent(ctx context.Context, cnrID *cid.ID, treeID string, id uint64) (uint64, error) { func (c *TreeClient) getParent(ctx context.Context, cnrID cid.ID, treeID string, id uint64) (uint64, error) {
subTree, err := c.getSubTree(ctx, cnrID, treeID, id, 0) subTree, err := c.getSubTree(ctx, cnrID, treeID, id, 0)
if err != nil { if err != nil {
return 0, err return 0, err
@ -1105,7 +1105,7 @@ func (c *TreeClient) getParent(ctx context.Context, cnrID *cid.ID, treeID string
return subTree[0].GetParentId(), nil return subTree[0].GetParentId(), nil
} }
func (c *TreeClient) getSubTree(ctx context.Context, cnrID *cid.ID, treeID string, rootID uint64, depth uint32) ([]*tree.GetSubTreeResponse_Body, error) { func (c *TreeClient) getSubTree(ctx context.Context, cnrID cid.ID, treeID string, rootID uint64, depth uint32) ([]*tree.GetSubTreeResponse_Body, error) {
request := &tree.GetSubTreeRequest{ request := &tree.GetSubTreeRequest{
Body: &tree.GetSubTreeRequest_Body{ Body: &tree.GetSubTreeRequest_Body{
ContainerId: cnrID[:], ContainerId: cnrID[:],
@ -1169,15 +1169,15 @@ func metaFromMultipart(info *data.MultipartInfo) map[string]string {
return info.Meta return info.Meta
} }
func (c *TreeClient) getSystemNode(ctx context.Context, cnrID *cid.ID, path, meta []string) (*TreeNode, error) { func (c *TreeClient) getSystemNode(ctx context.Context, cnrID cid.ID, path, meta []string) (*TreeNode, error) {
return c.getNode(ctx, cnrID, systemTree, path, meta, false) return c.getNode(ctx, cnrID, systemTree, path, meta, false)
} }
func (c *TreeClient) getSystemNodeWithAllAttributes(ctx context.Context, cnrID *cid.ID, path []string) (*TreeNode, error) { func (c *TreeClient) getSystemNodeWithAllAttributes(ctx context.Context, cnrID cid.ID, path []string) (*TreeNode, error) {
return c.getNode(ctx, cnrID, systemTree, path, []string{}, true) return c.getNode(ctx, cnrID, systemTree, path, []string{}, true)
} }
func (c *TreeClient) getNode(ctx context.Context, cnrID *cid.ID, treeID string, path, meta []string, allAttrs bool) (*TreeNode, error) { func (c *TreeClient) getNode(ctx context.Context, cnrID cid.ID, treeID string, path, meta []string, allAttrs bool) (*TreeNode, error) {
p := &getNodesParams{ p := &getNodesParams{
CnrID: cnrID, CnrID: cnrID,
TreeID: treeID, TreeID: treeID,
@ -1243,7 +1243,7 @@ func getBearer(ctx context.Context) []byte {
return nil return nil
} }
func (c *TreeClient) addNode(ctx context.Context, cnrID *cid.ID, treeID string, parent uint64, meta map[string]string) (uint64, error) { func (c *TreeClient) addNode(ctx context.Context, cnrID cid.ID, treeID string, parent uint64, meta map[string]string) (uint64, error) {
request := &tree.AddRequest{ request := &tree.AddRequest{
Body: &tree.AddRequest_Body{ Body: &tree.AddRequest_Body{
ContainerId: cnrID[:], ContainerId: cnrID[:],
@ -1270,7 +1270,7 @@ func (c *TreeClient) addNode(ctx context.Context, cnrID *cid.ID, treeID string,
return resp.GetBody().GetNodeId(), nil return resp.GetBody().GetNodeId(), nil
} }
func (c *TreeClient) addNodeByPath(ctx context.Context, cnrID *cid.ID, treeID string, path []string, meta map[string]string) error { func (c *TreeClient) addNodeByPath(ctx context.Context, cnrID cid.ID, treeID string, path []string, meta map[string]string) error {
request := &tree.AddByPathRequest{ request := &tree.AddByPathRequest{
Body: &tree.AddByPathRequest_Body{ Body: &tree.AddByPathRequest_Body{
ContainerId: cnrID[:], ContainerId: cnrID[:],
@ -1295,7 +1295,7 @@ func (c *TreeClient) addNodeByPath(ctx context.Context, cnrID *cid.ID, treeID st
return err return err
} }
func (c *TreeClient) moveNode(ctx context.Context, cnrID *cid.ID, treeID string, nodeID, parentID uint64, meta map[string]string) error { func (c *TreeClient) moveNode(ctx context.Context, cnrID cid.ID, treeID string, nodeID, parentID uint64, meta map[string]string) error {
request := &tree.MoveRequest{ request := &tree.MoveRequest{
Body: &tree.MoveRequest_Body{ Body: &tree.MoveRequest_Body{
ContainerId: cnrID[:], ContainerId: cnrID[:],
@ -1320,7 +1320,7 @@ func (c *TreeClient) moveNode(ctx context.Context, cnrID *cid.ID, treeID string,
return err return err
} }
func (c *TreeClient) removeNode(ctx context.Context, cnrID *cid.ID, treeID string, nodeID uint64) error { func (c *TreeClient) removeNode(ctx context.Context, cnrID cid.ID, treeID string, nodeID uint64) error {
request := &tree.RemoveRequest{ request := &tree.RemoveRequest{
Body: &tree.RemoveRequest_Body{ Body: &tree.RemoveRequest_Body{
ContainerId: cnrID[:], ContainerId: cnrID[:],