Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from overbool/fix/issue-#6
Browse files Browse the repository at this point in the history
fix(unixfs): issue #6
  • Loading branch information
Stebalien authored Sep 24, 2018
2 parents 3e00c63 + 820510f commit f510bf6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func (d *Directory) childNode(name string) (FSNode, error) {
func (d *Directory) cacheNode(name string, nd ipld.Node) (FSNode, error) {
switch nd := nd.(type) {
case *dag.ProtoNode:
i, err := ft.FromBytes(nd.Data())
fsn, err := ft.FSNodeFromBytes(nd.Data())
if err != nil {
return nil, err
}

switch i.GetType() {
switch fsn.Type() {
case ufspb.Data_Directory, ufspb.Data_HAMTShard:
ndir, err := NewDirectory(d.ctx, name, nd, d, d.dserv)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func (fi *File) Size() (int64, error) {
defer fi.nodelk.Unlock()
switch nd := fi.node.(type) {
case *dag.ProtoNode:
pbd, err := ft.FromBytes(nd.Data())
fsn, err := ft.FSNodeFromBytes(nd.Data())
if err != nil {
return 0, err
}
return int64(pbd.GetFilesize()), nil
return int64(fsn.FileSize()), nil
case *dag.RawNode:
return int64(len(nd.RawData())), nil
default:
Expand Down
8 changes: 4 additions & 4 deletions system.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf
repub: repub,
}

pbn, err := ft.FromBytes(node.Data())
fsn, err := ft.FSNodeFromBytes(node.Data())
if err != nil {
log.Error("IPNS pointer was not unixfs node")
return nil, err
}

switch pbn.GetType() {
switch fsn.Type() {
case ft.TDirectory, ft.THAMTShard:
newDir, err := NewDirectory(parent, node.String(), node, root, ds)
if err != nil {
Expand All @@ -89,9 +89,9 @@ func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf

root.dir = newDir
case ft.TFile, ft.TMetadata, ft.TRaw:
return nil, fmt.Errorf("root can't be a file (unixfs type: %s)", pbn.GetType())
return nil, fmt.Errorf("root can't be a file (unixfs type: %s)", fsn.Type())
default:
return nil, fmt.Errorf("unrecognized unixfs type: %s", pbn.GetType())
return nil, fmt.Errorf("unrecognized unixfs type: %s", fsn.Type())
}
return root, nil
}
Expand Down

0 comments on commit f510bf6

Please sign in to comment.