Skip to content

Commit

Permalink
Improve ErrNotFound
Browse files Browse the repository at this point in the history
Work with ipld.ErrNotFounds.
  • Loading branch information
hsanjuan committed Apr 7, 2020
1 parent d532cda commit 7f5d9e6
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 72 deletions.
2 changes: 1 addition & 1 deletion dagutils/diffenum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestDiffEnumFail(t *testing.T) {
}

err := DiffEnumerate(ctx, lgds, nds["a1"].Cid(), nds["a2"].Cid())
if err != ipld.ErrNotFound {
if !ipld.IsNotFound(err) {
t.Fatal("expected err not found")
}

Expand Down
6 changes: 3 additions & 3 deletions dagutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path
if err == dag.ErrLinkNotFound && create != nil {
nd = create()
err = nil // no longer an error case
} else if err == ipld.ErrNotFound {
} else if ipld.IsNotFound(err) {
// try finding it in our source dagstore
nd, err = root.GetLinkedProtoNode(ctx, e.src, path[0])
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string)

// search for node in both tmp dagstore and source dagstore
nd, err := root.GetLinkedProtoNode(ctx, e.tmp, path[0])
if err == ipld.ErrNotFound {
if ipld.IsNotFound(err) {
nd, err = root.GetLinkedProtoNode(ctx, e.src, path[0])
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func copyDag(ctx context.Context, nd ipld.Node, from, to ipld.DAGService) error
for _, lnk := range nd.Links() {
child, err := lnk.GetNode(ctx, from)
if err != nil {
if err == ipld.ErrNotFound {
if ipld.IsNotFound(err) {
// not found means we didnt modify it, and it should
// already be in the target datastore
continue
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/ipfs/go-merkledag
require (
github.com/gogo/protobuf v1.3.1
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.0
github.com/ipfs/go-cid v0.0.3
github.com/ipfs/go-datastore v0.3.1
github.com/ipfs/go-ipfs-blockstore v0.1.0
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-blockservice v0.1.4-0.20200407214602-071562482bcf
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-ipfs-blockstore v1.0.1-0.20200407212108-882f63676be9
github.com/ipfs/go-ipfs-exchange-offline v0.0.2-0.20200407220152-ef546a7fe3f1
github.com/ipfs/go-ipfs-util v0.0.1
github.com/ipfs/go-ipld-cbor v0.0.3
github.com/ipfs/go-ipld-format v0.0.2
github.com/multiformats/go-multihash v0.0.10
github.com/ipfs/go-ipld-format v0.1.0
github.com/multiformats/go-multihash v0.0.13
)

go 1.12
Loading

0 comments on commit 7f5d9e6

Please sign in to comment.