From f7388cc3ce57fb8cb4217da76ca30039696793a9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 16 Feb 2018 00:09:50 +0100 Subject: [PATCH] Feat: Separate "path" from "path/resolver" Currently the "path" module does two very different things: * Defines how ipfs paths look like and provides tools to parse/split etc. * Provides a resolver to resolve paths. This moves the resolver stuff to `path/resolver` and leaves the path utilities in `path`. The result is that now the IPFS `path` package just defines what a path looks like and becomes a module that can be exported/re-used without problems. Currently there are circular dependency cycles (resolve_test -> merkledag/utils, merkledag->path), which the prevent the export of merkledag itself. License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@93d1a695d49867fcd530cd236ed6dd43ab454c50 --- gateway/core/corehttp/gateway_handler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fed287594..842d30d46 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,6 +19,7 @@ import ( dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" + resolver "github.com/ipfs/go-ipfs/path/resolver" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" @@ -445,7 +446,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newcid *cid.Cid rnode, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { - case path.ErrNoLink: + case resolver.ErrNoLink: // ev.Node < node where resolve failed // ev.Name < new link // but we need to patch from the root @@ -599,7 +600,7 @@ func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { } func webError(w http.ResponseWriter, message string, err error, defaultCode int) { - if _, ok := err.(path.ErrNoLink); ok { + if _, ok := err.(resolver.ErrNoLink); ok { webErrorWithCode(w, message, err, http.StatusNotFound) } else if err == routing.ErrNotFound { webErrorWithCode(w, message, err, http.StatusNotFound)