Commit 77ff92dc authored by Cory Schwartz's avatar Cory Schwartz

io/dagreader.go

parent 68c015a6
......@@ -56,9 +56,27 @@ func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.NodeGetter) (DagRe
}
switch fsNode.Type() {
case unixfs.TFile, unixfs.TRaw:
case unixfs.TFile:
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
......
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