@@ -15,10 +15,11 @@ import (
15
15
iface "github.com/ipfs/go-ipfs/core/coreapi/interface"
16
16
17
17
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
18
+ mfs "gx/ipfs/QmQr1qYm6Ww3ePruqLs2QhSZAHHsW2CzePNTEp48AT3Mg1/go-mfs"
18
19
cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
19
20
ft "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs"
20
- mfs "gx/ipfs/QmV8mXUh1M9qztax7vVdL1Apuz4c1eJZC5YactGxaJfWom/go-mfs"
21
21
bservice "gx/ipfs/QmVDTbzzTwnuBwNbJdhW3u7LoBQp46bezm9yp4z1RoEepM/go-blockservice"
22
+ apicid "gx/ipfs/QmVjZoEZg2oxXGFGjbD28x3gGN6ALHAW6BN2LKRUcaJ21i/go-cidutil/apicid"
22
23
offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline"
23
24
cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds"
24
25
dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag"
@@ -76,7 +77,7 @@ var hashOption = cmdkit.StringOption(filesHashOptionName, "Hash function to use.
76
77
var errFormat = errors .New ("format was set by multiple options. Only one format option is allowed" )
77
78
78
79
type statOutput struct {
79
- Hash string
80
+ Hash apicid. Hash
80
81
Size uint64
81
82
CumulativeSize uint64
82
83
Blocks int
@@ -172,7 +173,7 @@ var filesStatCmd = &cmds.Command{
172
173
Encoders : cmds.EncoderMap {
173
174
cmds .Text : cmds .MakeTypedEncoder (func (req * cmds.Request , w io.Writer , out * statOutput ) error {
174
175
s , _ := statGetFormatOptions (req )
175
- s = strings .Replace (s , "<hash>" , out .Hash , - 1 )
176
+ s = strings .Replace (s , "<hash>" , out .Hash . String () , - 1 )
176
177
s = strings .Replace (s , "<size>" , fmt .Sprintf ("%d" , out .Size ), - 1 )
177
178
s = strings .Replace (s , "<cumulsize>" , fmt .Sprintf ("%d" , out .CumulativeSize ), - 1 )
178
179
s = strings .Replace (s , "<childs>" , fmt .Sprintf ("%d" , out .Blocks ), - 1 )
@@ -243,15 +244,15 @@ func statNode(nd ipld.Node) (*statOutput, error) {
243
244
}
244
245
245
246
return & statOutput {
246
- Hash : c . String ( ),
247
+ Hash : apicid . FromCid ( c ),
247
248
Blocks : len (nd .Links ()),
248
249
Size : d .FileSize (),
249
250
CumulativeSize : cumulsize ,
250
251
Type : ndtype ,
251
252
}, nil
252
253
case * dag.RawNode :
253
254
return & statOutput {
254
- Hash : c . String ( ),
255
+ Hash : apicid . FromCid ( c ),
255
256
Blocks : 0 ,
256
257
Size : cumulsize ,
257
258
CumulativeSize : cumulsize ,
@@ -470,7 +471,7 @@ Examples:
470
471
if err != nil {
471
472
return err
472
473
}
473
- out .Entries [0 ].Hash = nd .Cid (). String ( )
474
+ out .Entries [0 ].Hash = apicid . FromCid ( nd .Cid ())
474
475
}
475
476
return cmds .EmitOnce (res , out )
476
477
default :
0 commit comments