From 48c3effac887614671d22d58f912f5e135a46f3c Mon Sep 17 00:00:00 2001 From: Overbool Date: Fri, 21 Sep 2018 13:21:39 +0800 Subject: [PATCH] fix(unixfs): issue #5217 License: MIT Signed-off-by: Overbool --- core/commands/files.go | 8 ++++---- core/commands/ls.go | 4 ++-- core/commands/unixfs/ls.go | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/commands/files.go b/core/commands/files.go index 50e7bde0ae1..499139774a2 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -223,25 +223,25 @@ func statNode(nd ipld.Node) (*statOutput, error) { switch n := nd.(type) { case *dag.ProtoNode: - d, err := ft.FromBytes(n.Data()) + d, err := ft.FSNodeFromBytes(n.Data()) if err != nil { return nil, err } var ndtype string - switch d.GetType() { + switch d.Type() { case ft.TDirectory, ft.THAMTShard: ndtype = "directory" case ft.TFile, ft.TMetadata, ft.TRaw: ndtype = "file" default: - return nil, fmt.Errorf("unrecognized node type: %s", d.GetType()) + return nil, fmt.Errorf("unrecognized node type: %s", d.Type()) } return &statOutput{ Hash: c.String(), Blocks: len(nd.Links()), - Size: d.GetFilesize(), + Size: d.FileSize(), CumulativeSize: cumulsize, Type: ndtype, }, nil diff --git a/core/commands/ls.go b/core/commands/ls.go index 566e0ad0135..d6c257df98a 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -150,12 +150,12 @@ The JSON output contains type information. } if pn, ok := linkNode.(*merkledag.ProtoNode); ok { - d, err := unixfs.FromBytes(pn.Data()) + d, err := unixfs.FSNodeFromBytes(pn.Data()) if err != nil { res.SetError(err, cmdkit.ErrNormal) return } - t = d.GetType() + t = d.Type() } } output[i].Links[j] = LsLink{ diff --git a/core/commands/unixfs/ls.go b/core/commands/unixfs/ls.go index b9ba2b28017..d355815785b 100644 --- a/core/commands/unixfs/ls.go +++ b/core/commands/unixfs/ls.go @@ -120,18 +120,18 @@ possible, please use 'ipfs ls' instead. return } - unixFSNode, err := unixfs.FromBytes(ndpb.Data()) + unixFSNode, err := unixfs.FSNodeFromBytes(ndpb.Data()) if err != nil { res.SetError(err, cmdkit.ErrNormal) return } - t := unixFSNode.GetType() + t := unixFSNode.Type() output.Objects[hash] = &LsObject{ Hash: c.String(), Type: t.String(), - Size: unixFSNode.GetFilesize(), + Size: unixFSNode.FileSize(), } switch t { @@ -156,19 +156,19 @@ possible, please use 'ipfs ls' instead. return } - d, err := unixfs.FromBytes(lnpb.Data()) + d, err := unixfs.FSNodeFromBytes(lnpb.Data()) if err != nil { res.SetError(err, cmdkit.ErrNormal) return } - t := d.GetType() + t := d.Type() lsLink := LsLink{ Name: link.Name, Hash: link.Cid.String(), Type: t.String(), } if t == unixfspb.Data_File { - lsLink.Size = d.GetFilesize() + lsLink.Size = d.FileSize() } else { lsLink.Size = link.Size }