[#1753] services/tree: Add parent ID to the GetNodeByPath response

Currently, you need to use `GetSubTree` to get parent, which seems an
overkill.

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-09-05 16:46:56 +03:00 committed by fyrchik
parent 8a47f9ba12
commit 74c861342e
6 changed files with 4 additions and 1 deletions

View file

@ -308,12 +308,13 @@ func (s *Service) GetNodeByPath(ctx context.Context, req *GetNodeByPathRequest)
info := make([]*GetNodeByPathResponse_Info, 0, len(nodes)) info := make([]*GetNodeByPathResponse_Info, 0, len(nodes))
for _, node := range nodes { for _, node := range nodes {
m, _, err := s.forest.TreeGetMeta(cid, b.GetTreeId(), node) m, parent, err := s.forest.TreeGetMeta(cid, b.GetTreeId(), node)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var x GetNodeByPathResponse_Info var x GetNodeByPathResponse_Info
x.ParentId = parent
x.NodeId = node x.NodeId = node
x.Timestamp = m.Time x.Timestamp = m.Time
if b.AllAttributes { if b.AllAttributes {

Binary file not shown.

View file

@ -202,6 +202,8 @@ message GetNodeByPathResponse {
uint64 timestamp = 2; uint64 timestamp = 2;
// Node meta-information. // Node meta-information.
repeated KeyValue meta = 3; repeated KeyValue meta = 3;
// Parent ID.
uint64 parent_id = 4;
} }
message Body { message Body {
// List of nodes stored by path. // List of nodes stored by path.

Binary file not shown.

Binary file not shown.

Binary file not shown.