Commit 7e96bad9 authored by Cory Schwartz's avatar Cory Schwartz

Fix in size func

parent 77ff92dc
......@@ -56,27 +56,9 @@ func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.NodeGetter) (DagRe
}
switch fsNode.Type() {
case unixfs.TFile:
case unixfs.TFile, unixfs.TRaw:
size = fsNode.FileSize()
case unixfs.TRaw:
stat, err := n.Stat()
if err != nil {
return nil, err
}
size = uint64(stat.DataSize)
for _, link := range n.Links() {
ln, err := link.GetNode(ctx, serv)
if err != nil {
return nil, err
}
stat, err := ln.Stat()
if err != nil {
return nil, err
}
size += uint64(stat.DataSize)
}
case unixfs.TDirectory, unixfs.THAMTShard:
// Dont allow reading directories
return nil, ErrIsDir
......
......@@ -159,9 +159,9 @@ func size(pbdata *pb.Data) (uint64, error) {
switch pbdata.GetType() {
case pb.Data_Directory, pb.Data_HAMTShard:
return 0, errors.New("can't get data size of directory")
case pb.Data_File:
case pb.Data_File, pb.Data_Raw:
return pbdata.GetFilesize(), nil
case pb.Data_Symlink, pb.Data_Raw:
case pb.Data_Symlink:
return uint64(len(pbdata.GetData())), nil
default:
return 0, errors.New("unrecognized node data type")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment