Skip to content

Commit

Permalink
Merge pull request #6601 from ipfs/fix/6595
Browse files Browse the repository at this point in the history
cmds/refs: fix ipfs refs for sharded directories
  • Loading branch information
Stebalien committed Aug 22, 2019
2 parents d61269f + 4f6069f commit 4a87fea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 7 additions & 13 deletions core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -103,14 +102,14 @@ NOTE: List all references recursively by using the flag '-r'.
format = "<src> -> <dst>"
}

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,
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 4a87fea

Please sign in to comment.