[#1642] tree: Intoduce a helper LastChild
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
760b6a44ea
commit
39f549a7ab
2 changed files with 5 additions and 1 deletions
|
@ -1155,7 +1155,7 @@ func (t *boltForest) TreeSortedByFilename(ctx context.Context, cid cidSDK.ID, tr
|
|||
}
|
||||
if len(res) != 0 {
|
||||
s := string(findAttr(res[len(res)-1].Meta, AttributeFilename))
|
||||
last = NewCursor(s, res[len(res)-1].Children[len(res[len(res)-1].Children)-1])
|
||||
last = NewCursor(s, res[len(res)-1].LastChild())
|
||||
}
|
||||
return res, last, metaerr.Wrap(err)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,10 @@ func (r *MultiNodeInfo) Add(info NodeInfo) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (r *MultiNodeInfo) LastChild() Node {
|
||||
return r.Children[len(r.Children)-1]
|
||||
}
|
||||
|
||||
func (n NodeInfo) ToMultiNode() MultiNodeInfo {
|
||||
return MultiNodeInfo{
|
||||
Children: MultiNode{n.ID},
|
||||
|
|
Loading…
Add table
Reference in a new issue