[#624] Update tree service revision

Remove extra request to tree service to know parentID

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-09-07 11:46:08 +03:00 committed by Kirillov Denis
parent e33d6fceda
commit 6108f8d929
3 changed files with 7 additions and 16 deletions

View file

@ -50,6 +50,7 @@ func (e ExtendedObjectInfo) Version() string {
// Basically used for "system" object. // Basically used for "system" object.
type BaseNodeVersion struct { type BaseNodeVersion struct {
ID uint64 ID uint64
ParenID uint64
OID oid.ID OID oid.ID
Timestamp uint64 Timestamp uint64
Size int64 Size int64

View file

@ -31,6 +31,7 @@ type (
TreeNode struct { TreeNode struct {
ID uint64 ID uint64
ParentID uint64
ObjID oid.ID ObjID oid.ID
TimeStamp uint64 TimeStamp uint64
Size int64 Size int64
@ -109,12 +110,14 @@ func NewTreeClient(addr string, key *keys.PrivateKey) (*TreeClient, error) {
type NodeResponse interface { type NodeResponse interface {
GetMeta() []*tree.KeyValue GetMeta() []*tree.KeyValue
GetNodeId() uint64 GetNodeId() uint64
GetParentId() uint64
GetTimestamp() uint64 GetTimestamp() uint64
} }
func newTreeNode(nodeInfo NodeResponse) (*TreeNode, error) { func newTreeNode(nodeInfo NodeResponse) (*TreeNode, error) {
treeNode := &TreeNode{ treeNode := &TreeNode{
ID: nodeInfo.GetNodeId(), ID: nodeInfo.GetNodeId(),
ParentID: nodeInfo.GetParentId(),
TimeStamp: nodeInfo.GetTimestamp(), TimeStamp: nodeInfo.GetTimestamp(),
Meta: make(map[string]string, len(nodeInfo.GetMeta())), Meta: make(map[string]string, len(nodeInfo.GetMeta())),
} }
@ -171,6 +174,7 @@ func newNodeVersionFromTreeNode(filePath string, treeNode *TreeNode) *data.NodeV
version := &data.NodeVersion{ version := &data.NodeVersion{
BaseNodeVersion: data.BaseNodeVersion{ BaseNodeVersion: data.BaseNodeVersion{
ID: treeNode.ID, ID: treeNode.ID,
ParenID: treeNode.ParentID,
OID: treeNode.ObjID, OID: treeNode.ObjID,
Timestamp: treeNode.TimeStamp, Timestamp: treeNode.TimeStamp,
ETag: eTag, ETag: eTag,
@ -1078,12 +1082,7 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string
node, err := c.getUnversioned(ctx, cnrID, treeID, version.FilePath) node, err := c.getUnversioned(ctx, cnrID, treeID, version.FilePath)
if err == nil { if err == nil {
parentID, err := c.getParent(ctx, cnrID, treeID, node.ID) if err = c.moveNode(ctx, cnrID, treeID, node.ID, node.ParenID, meta); err != nil {
if err != nil {
return 0, err
}
if err = c.moveNode(ctx, cnrID, treeID, node.ID, parentID, meta); err != nil {
return 0, err return 0, err
} }
@ -1146,15 +1145,6 @@ func (c *TreeClient) getVersions(ctx context.Context, cnrID cid.ID, treeID, file
return result, nil return result, nil
} }
func (c *TreeClient) getParent(ctx context.Context, cnrID cid.ID, treeID string, id uint64) (uint64, error) {
subTree, err := c.getSubTree(ctx, cnrID, treeID, id, 1)
if err != nil {
return 0, err
}
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{

View file

@ -2,7 +2,7 @@
mkdir -p internal/neofs/services/tree 2>/dev/null mkdir -p internal/neofs/services/tree 2>/dev/null
REVISION="1678fe44ed2bdac1c3ae3421d2cc500c2be87a98" REVISION="74c861342e19611dba534bb719aafda757f0d009"
echo "tree service revision ${REVISION}" echo "tree service revision ${REVISION}"