Skip to content

Commit

Permalink
ipfs: disambiguate path resolver's error kinds
Browse files Browse the repository at this point in the history
Without this we'll default to returning an IO error, which breaks some
programs that would otherwise expect/handle a "not found" error kind.
  • Loading branch information
djdv committed Sep 15, 2023
1 parent a4e8c5c commit 604993b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/filesystem/ipfs/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
dag "github.com/ipfs/boxo/ipld/merkledag"
"github.com/ipfs/boxo/ipld/unixfs"
unixpb "github.com/ipfs/boxo/ipld/unixfs/pb"
"github.com/ipfs/boxo/path/resolver"
ipfscmds "github.com/ipfs/go-ipfs-cmds"
cbor "github.com/ipfs/go-ipld-cbor"
ipld "github.com/ipfs/go-ipld-format"
Expand Down Expand Up @@ -257,6 +258,10 @@ func cidErrKind(err error) fserrors.Kind {
}

func resolveErrKind(err error) fserrors.Kind {
var resolveErr resolver.ErrNoLink
if errors.As(err, &resolveErr) {
return fserrors.NotExist
}
// XXX: Upstream doesn't define error values
// to compare against. We have to fallback to strings.
// This could break at any time.
Expand Down

0 comments on commit 604993b

Please sign in to comment.