From 0440894d322556dba09f176513e6051682271d8c Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Tue, 25 Sep 2018 14:55:39 -0400 Subject: [PATCH] Use apicid.Hash for `ipfs file ls`. License: MIT Signed-off-by: Kevin Atkinson --- core/commands/unixfs/ls.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go index 598823cfa9b1..20b5125d245d 100644 --- a/core/commands/unixfs/ls.go +++ b/core/commands/unixfs/ls.go @@ -9,6 +9,9 @@ import ( cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit" + cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + apicid "gx/ipfs/QmNWQygwYxgz3QzXG2ytTkrHkZ4HnnSh94ASox3JjktFcR/go-cidutil/apicid" + cmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" e "github.com/ipfs/go-ipfs/core/commands/e" @@ -26,7 +29,7 @@ type LsLink struct { } type LsObject struct { - Hash string + Hash apicid.Hash Size uint64 Type string Links []LsLink @@ -128,7 +131,7 @@ possible, please use 'ipfs ls' instead. t := unixFSNode.Type() output.Objects[hash] = &LsObject{ - Hash: c.String(), + Hash: apicid.FromCid(c), Type: t.String(), Size: unixFSNode.FileSize(), } @@ -186,6 +189,11 @@ possible, please use 'ipfs ls' instead. }, Marshalers: cmds.MarshalerMap{ cmds.Text: func(res cmds.Response) (io.Reader, error) { + _, err := cmdenv.NewCidBaseHandlerLegacy(res.Request()).UseGlobal().Proc() + if err != nil { + return nil, err + } + v, err := unwrapOutput(res.Output()) if err != nil { return nil, err