Skip to content

Commit

Permalink
Feat: Separate "path" from "path/resolver"
Browse files Browse the repository at this point in the history
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 <hector@protocol.ai>


This commit was moved from ipfs/kubo@93d1a69
  • Loading branch information
hsanjuan committed Feb 15, 2018
1 parent 8a44695 commit f7388cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f7388cc

Please sign in to comment.