diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-08 00:33:47 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-08 01:28:15 -0600 |
commit | 7e09476e6cf9922baa3c3a49b559b5b9af970561 (patch) | |
tree | a7f5717f5d5a336193b1695e4bd980cf3c50ddae /pkg/btrfs/io3_btree.go | |
parent | cea13f5e842b488049c4d15e9a7b27171ce420c8 (diff) |
fix tree search
Diffstat (limited to 'pkg/btrfs/io3_btree.go')
-rw-r--r-- | pkg/btrfs/io3_btree.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/btrfs/io3_btree.go b/pkg/btrfs/io3_btree.go index 9ba3be1..1bcb193 100644 --- a/pkg/btrfs/io3_btree.go +++ b/pkg/btrfs/io3_btree.go @@ -278,7 +278,7 @@ func (fs *FS) treeSearch(treeRoot btrfsvol.LogicalAddr, fn func(Key) int) (TreeP // // Implement this search as a binary search. beg := 0 - end := len(node.Data.BodyLeaf) - 1 + end := len(node.Data.BodyLeaf) for beg < end { midpoint := (beg + end) / 2 direction := fn(node.Data.BodyLeaf[midpoint].Head.Key) @@ -427,7 +427,11 @@ func (fs *FS) TreeSearch(treeRoot btrfsvol.LogicalAddr, fn func(Key) int) (Item, } func (fs *FS) TreeLookup(treeRoot btrfsvol.LogicalAddr, key Key) (Item, error) { - return fs.TreeSearch(treeRoot, key.Cmp) + item, err := fs.TreeSearch(treeRoot, key.Cmp) + if err != nil { + err = fmt.Errorf("item with key=%v: %w", key, err) + } + return item, err } // If some items are able to be read, but there is an error reading the full set, then it might |