提交 4f6069f2 作者: Steven Allen

cmds/refs: fix ipfs refs for sharded directories

fixes #6596
上级 d61269f4
...@@ -7,15 +7,14 @@ import ( ...@@ -7,15 +7,14 @@ import (
"io" "io"
"strings" "strings"
core "github.com/ipfs/go-ipfs/core"
cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv"
"github.com/ipfs/go-ipfs/namesys/resolve"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cidenc "github.com/ipfs/go-cidutil/cidenc" cidenc "github.com/ipfs/go-cidutil/cidenc"
cmds "github.com/ipfs/go-ipfs-cmds" cmds "github.com/ipfs/go-ipfs-cmds"
ipld "github.com/ipfs/go-ipld-format" 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{ var refsEncoderMap = cmds.EncoderMap{
...@@ -75,7 +74,7 @@ NOTE: List all references recursively by using the flag '-r'. ...@@ -75,7 +74,7 @@ NOTE: List all references recursively by using the flag '-r'.
} }
ctx := req.Context ctx := req.Context
n, err := cmdenv.GetNode(env) api, err := cmdenv.GetApi(env, req)
if err != nil { if err != nil {
return err return err
} }
...@@ -103,14 +102,14 @@ NOTE: List all references recursively by using the flag '-r'. ...@@ -103,14 +102,14 @@ NOTE: List all references recursively by using the flag '-r'.
format = "<src> -> <dst>" format = "<src> -> <dst>"
} }
objs, err := objectsForPaths(ctx, n, req.Arguments) objs, err := objectsForPaths(ctx, api, req.Arguments)
if err != nil { if err != nil {
return err return err
} }
rw := RefWriter{ rw := RefWriter{
res: res, res: res,
DAG: n.DAG, DAG: api.Dag(),
Ctx: ctx, Ctx: ctx,
Unique: unique, Unique: unique,
PrintFmt: format, PrintFmt: format,
...@@ -165,15 +164,10 @@ Displays the hashes of all local objects. ...@@ -165,15 +164,10 @@ Displays the hashes of all local objects.
Type: RefWrapper{}, 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)) objects := make([]ipld.Node, len(paths))
for i, sp := range paths { for i, sp := range paths {
p, err := path.ParsePath(sp) o, err := n.ResolveNode(ctx, path.New(sp))
if err != nil {
return nil, err
}
o, err := resolve.Resolve(ctx, n.Namesys, n.Resolver, p)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -110,7 +110,6 @@ require ( ...@@ -110,7 +110,6 @@ require (
go.uber.org/multierr v1.1.0 // indirect go.uber.org/multierr v1.1.0 // indirect
go4.org v0.0.0-20190313082347-94abd6928b1d // indirect go4.org v0.0.0-20190313082347-94abd6928b1d // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb 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 gopkg.in/cheggaaa/pb.v1 v1.0.28
gotest.tools/gotestsum v0.3.4 gotest.tools/gotestsum v0.3.4
) )
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论