diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go index b1dc2102167..3ed9d373343 100644 --- a/core/commands/unixfs/ls.go +++ b/core/commands/unixfs/ls.go @@ -19,7 +19,7 @@ import ( type LsLink struct { Name, Hash string Size uint64 - Type unixfspb.Data_DataType + Type string } type LsObject struct { @@ -88,7 +88,7 @@ directories, the child size is the IPFS link size. output[i].Links = []LsLink{LsLink{ Name: fpath, Hash: key.String(), - Type: t, + Type: t.String(), Size: unixFSNode.GetFilesize(), }} case unixfspb.Data_Directory: @@ -106,12 +106,13 @@ directories, the child size is the IPFS link size. res.SetError(err, cmds.ErrNormal) return } + t := d.GetType() lsLink := LsLink{ Name: link.Name, Hash: link.Hash.B58String(), - Type: d.GetType(), + Type: t.String(), } - if lsLink.Type == unixfspb.Data_File { + if t == unixfspb.Data_File { lsLink.Size = d.GetFilesize() } else { lsLink.Size = link.Size diff --git a/test/sharness/t0200-unixfs-ls.sh b/test/sharness/t0200-unixfs-ls.sh index 64462f93cf3..414eece60c4 100755 --- a/test/sharness/t0200-unixfs-ls.sh +++ b/test/sharness/t0200-unixfs-ls.sh @@ -88,7 +88,7 @@ test_ls_cmd() { "Name": "/ipfs/QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy/1024", "Hash": "QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd", "Size": 1024, - "Type": 2 + "Type": "File" } ] }