[#413] Add stream reading

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-05-19 11:13:25 +03:00 committed by Alex Vanin
parent 1e86413667
commit 332de834ae

View file

@ -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
}