From 4f6069f2183ad99b87ca227fdd0f731e3528a5a9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 21 Aug 2019 18:25:46 -0700 Subject: [PATCH] cmds/refs: fix ipfs refs for sharded directories fixes #6596 --- core/commands/refs.go | 20 +++++++------------- go.mod | 1 - 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/core/commands/refs.go b/core/commands/refs.go index acb72537671..4a7285cc95c 100644 --- a/core/commands/refs.go +++ b/core/commands/refs.go @@ -7,15 +7,14 @@ import ( "io" "strings" - core "github.com/ipfs/go-ipfs/core" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "github.com/ipfs/go-ipfs/namesys/resolve" cid "github.com/ipfs/go-cid" cidenc "github.com/ipfs/go-cidutil/cidenc" cmds "github.com/ipfs/go-ipfs-cmds" ipld "github.com/ipfs/go-ipld-format" - path "github.com/ipfs/go-path" + iface "github.com/ipfs/interface-go-ipfs-core" + path "github.com/ipfs/interface-go-ipfs-core/path" ) var refsEncoderMap = cmds.EncoderMap{ @@ -75,7 +74,7 @@ NOTE: List all references recursively by using the flag '-r'. } ctx := req.Context - n, err := cmdenv.GetNode(env) + api, err := cmdenv.GetApi(env, req) if err != nil { return err } @@ -103,14 +102,14 @@ NOTE: List all references recursively by using the flag '-r'. format = " -> " } - objs, err := objectsForPaths(ctx, n, req.Arguments) + objs, err := objectsForPaths(ctx, api, req.Arguments) if err != nil { return err } rw := RefWriter{ res: res, - DAG: n.DAG, + DAG: api.Dag(), Ctx: ctx, Unique: unique, PrintFmt: format, @@ -165,15 +164,10 @@ Displays the hashes of all local objects. Type: RefWrapper{}, } -func objectsForPaths(ctx context.Context, n *core.IpfsNode, paths []string) ([]ipld.Node, error) { +func objectsForPaths(ctx context.Context, n iface.CoreAPI, paths []string) ([]ipld.Node, error) { objects := make([]ipld.Node, len(paths)) for i, sp := range paths { - p, err := path.ParsePath(sp) - if err != nil { - return nil, err - } - - o, err := resolve.Resolve(ctx, n.Namesys, n.Resolver, p) + o, err := n.ResolveNode(ctx, path.New(sp)) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index eed74dc75fd..117a279507f 100644 --- a/go.mod +++ b/go.mod @@ -110,7 +110,6 @@ require ( go.uber.org/multierr v1.1.0 // indirect go4.org v0.0.0-20190313082347-94abd6928b1d // indirect golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb - google.golang.org/appengine v1.4.0 // indirect gopkg.in/cheggaaa/pb.v1 v1.0.28 gotest.tools/gotestsum v0.3.4 )