From 332de834ae0374c8fa0f0699f2fb36cd09d6b0d6 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 19 May 2022 11:13:25 +0300 Subject: [PATCH] [#413] Add stream reading Signed-off-by: Denis Kirillov --- internal/neofs/tree.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/neofs/tree.go b/internal/neofs/tree.go index 2f5d05813..a7eb2d40d 100644 --- a/internal/neofs/tree.go +++ b/internal/neofs/tree.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "strconv" "strings" @@ -406,6 +407,14 @@ func (c *TreeClient) getParent(ctx context.Context, cnrID *cid.ID, treeID string return 0, fmt.Errorf("failed to get sub tree: %w", err) } + for { + if _, err = cli.Recv(); err == io.EOF { + break + } else if err != nil { + return 0, fmt.Errorf("failed to read out sub tree stream: %w", err) + } + } + return resp.GetBody().GetParentId(), nil }