Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
7e96bad9
Commit
7e96bad9
authored
Apr 16, 2021
by
Cory Schwartz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix in size func
parent
77ff92dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
21 deletions
+3
-21
io/dagreader.go
io/dagreader.go
+1
-19
unixfs.go
unixfs.go
+2
-2
No files found.
io/dagreader.go
View file @
7e96bad9
...
...
@@ -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
...
...
unixfs.go
View file @
7e96bad9
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment