Skip to content

Commit 86a7017

Browse files
committed
Use apicid.Hash for ipfs file ls.
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent f5c2c22 commit 86a7017

File tree

1 file changed

+10
-2
lines changed
  • core/commands/unixfs

1 file changed

+10
-2
lines changed

core/commands/unixfs/ls.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99

1010
cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
1111

12+
cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv"
13+
apicid "gx/ipfs/QmNWQygwYxgz3QzXG2ytTkrHkZ4HnnSh94ASox3JjktFcR/go-cidutil/apicid"
14+
1215
cmds "github.com/ipfs/go-ipfs/commands"
1316
core "github.com/ipfs/go-ipfs/core"
1417
e "github.com/ipfs/go-ipfs/core/commands/e"
@@ -27,7 +30,7 @@ type LsLink struct {
2730
}
2831

2932
type LsObject struct {
30-
Hash string
33+
Hash apicid.Hash
3134
Size uint64
3235
Type string
3336
Links []LsLink
@@ -129,7 +132,7 @@ possible, please use 'ipfs ls' instead.
129132
t := unixFSNode.GetType()
130133

131134
output.Objects[hash] = &LsObject{
132-
Hash: c.String(),
135+
Hash: apicid.FromCid(c),
133136
Type: t.String(),
134137
Size: unixFSNode.GetFilesize(),
135138
}
@@ -187,6 +190,11 @@ possible, please use 'ipfs ls' instead.
187190
},
188191
Marshalers: cmds.MarshalerMap{
189192
cmds.Text: func(res cmds.Response) (io.Reader, error) {
193+
_, err := cmdenv.NewCidBaseHandlerLegacy(res.Request()).UseGlobal().Proc()
194+
if err != nil {
195+
return nil, err
196+
}
197+
190198
v, err := unwrapOutput(res.Output())
191199
if err != nil {
192200
return nil, err

0 commit comments

Comments
 (0)