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

Commit 77ff92d

Browse files
author
Cory Schwartz
committed
io/dagreader.go
1 parent 68c015a commit 77ff92d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Diff for: io/dagreader.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,27 @@ func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.NodeGetter) (DagRe
5656
}
5757

5858
switch fsNode.Type() {
59-
case unixfs.TFile, unixfs.TRaw:
59+
case unixfs.TFile:
6060
size = fsNode.FileSize()
6161

62+
case unixfs.TRaw:
63+
stat, err := n.Stat()
64+
if err != nil {
65+
return nil, err
66+
}
67+
size = uint64(stat.DataSize)
68+
for _, link := range n.Links() {
69+
ln, err := link.GetNode(ctx, serv)
70+
if err != nil {
71+
return nil, err
72+
}
73+
stat, err := ln.Stat()
74+
if err != nil {
75+
return nil, err
76+
}
77+
size += uint64(stat.DataSize)
78+
}
79+
6280
case unixfs.TDirectory, unixfs.THAMTShard:
6381
// Dont allow reading directories
6482
return nil, ErrIsDir

0 commit comments

Comments
 (0)