From 97bc89d56029f2275f42c9d8564151388c51bec9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 21 Aug 2019 19:25:07 -0700 Subject: [PATCH] resolve: kill off buggy resolve function This resolve function assumed that all paths were of the same type (ipfs, ipld, etc.). The CoreAPI does a much better job. --- namesys/resolve/pathresolver_test.go | 32 ---------------------------- namesys/resolve/resolve.go | 15 ------------- 2 files changed, 47 deletions(-) delete mode 100644 namesys/resolve/pathresolver_test.go diff --git a/namesys/resolve/pathresolver_test.go b/namesys/resolve/pathresolver_test.go deleted file mode 100644 index 3d9c04fa2f1..00000000000 --- a/namesys/resolve/pathresolver_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package resolve_test - -import ( - "testing" - - coremock "github.com/ipfs/go-ipfs/core/mock" - "github.com/ipfs/go-ipfs/namesys/resolve" - - path "github.com/ipfs/go-path" -) - -func TestResolveNoComponents(t *testing.T) { - n, err := coremock.NewMockNode() - if n == nil || err != nil { - t.Fatal("Should have constructed a mock node", err) - } - - _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipns/")) - if err.Error() != "invalid path \"/ipns/\": ipns path missing IPNS ID" { - t.Error("Should error with no components (/ipns/).", err) - } - - _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipfs/")) - if err.Error() != "invalid path \"/ipfs/\": not enough path components" { - t.Error("Should error with no components (/ipfs/).", err) - } - - _, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/../..")) - if err.Error() != "invalid path \"/../..\": unknown namespace \"..\"" { - t.Error("Should error with invalid path.", err) - } -} diff --git a/namesys/resolve/resolve.go b/namesys/resolve/resolve.go index 5b5dc515efe..f838a6611f7 100644 --- a/namesys/resolve/resolve.go +++ b/namesys/resolve/resolve.go @@ -6,9 +6,7 @@ import ( "fmt" "strings" - "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-path" - "github.com/ipfs/go-path/resolver" "github.com/ipfs/go-ipfs/namesys" ) @@ -52,16 +50,3 @@ func ResolveIPNS(ctx context.Context, nsys namesys.NameSystem, p path.Path) (pat } return p, nil } - -// Resolve resolves the given path by parsing out protocol-specific -// entries (e.g. /ipns/) and then going through the /ipfs/ -// entries and returning the final node. -func Resolve(ctx context.Context, nsys namesys.NameSystem, r *resolver.Resolver, p path.Path) (format.Node, error) { - p, err := ResolveIPNS(ctx, nsys, p) - if err != nil { - return nil, err - } - - // ok, we have an IPFS path now (or what we'll treat as one) - return r.ResolvePath(ctx, p) -}