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
323371cb
Unverified
Commit
323371cb
authored
Jan 30, 2019
by
Steven Allen
Committed by
GitHub
Jan 30, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #61 from ipfs/misc/archive-refactor
unixfile: precalc dir size
parents
0eb1ef8f
cdf04ae3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
.gx/lastpubver
.gx/lastpubver
+1
-1
file/unixfile.go
file/unixfile.go
+11
-9
package.json
package.json
+1
-1
No files found.
.gx/lastpubver
View file @
323371cb
1.3.
0
: Qm
UHJ8HKx96wtoMLAcHq2DB6H9V4aEUzbLtf8uGnfmtJoD
1.3.
1
: Qm
Q1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq
file/unixfile.go
View file @
323371cb
...
@@ -20,6 +20,7 @@ type ufsDirectory struct {
...
@@ -20,6 +20,7 @@ type ufsDirectory struct {
ctx
context
.
Context
ctx
context
.
Context
dserv
ipld
.
DAGService
dserv
ipld
.
DAGService
dir
uio
.
Directory
dir
uio
.
Directory
size
int64
}
}
type
ufsIterator
struct
{
type
ufsIterator
struct
{
...
@@ -118,12 +119,7 @@ func (d *ufsDirectory) Entries() files.DirIterator {
...
@@ -118,12 +119,7 @@ func (d *ufsDirectory) Entries() files.DirIterator {
}
}
func
(
d
*
ufsDirectory
)
Size
()
(
int64
,
error
)
{
func
(
d
*
ufsDirectory
)
Size
()
(
int64
,
error
)
{
n
,
err
:=
d
.
dir
.
GetNode
()
return
d
.
size
,
nil
if
err
!=
nil
{
return
0
,
err
}
s
,
err
:=
n
.
Size
()
return
int64
(
s
),
err
}
}
type
ufsFile
struct
{
type
ufsFile
struct
{
...
@@ -134,17 +130,23 @@ func (f *ufsFile) Size() (int64, error) {
...
@@ -134,17 +130,23 @@ func (f *ufsFile) Size() (int64, error) {
return
int64
(
f
.
DagReader
.
Size
()),
nil
return
int64
(
f
.
DagReader
.
Size
()),
nil
}
}
func
newUnixfsDir
(
ctx
context
.
Context
,
dserv
ipld
.
DAGService
,
nd
ipld
.
Node
)
(
files
.
Directory
,
error
)
{
func
newUnixfsDir
(
ctx
context
.
Context
,
dserv
ipld
.
DAGService
,
nd
*
dag
.
Proto
Node
)
(
files
.
Directory
,
error
)
{
dir
,
err
:=
uio
.
NewDirectoryFromNode
(
dserv
,
nd
)
dir
,
err
:=
uio
.
NewDirectoryFromNode
(
dserv
,
nd
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
size
,
err
:=
nd
.
Size
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
ufsDirectory
{
return
&
ufsDirectory
{
ctx
:
ctx
,
ctx
:
ctx
,
dserv
:
dserv
,
dserv
:
dserv
,
dir
:
dir
,
dir
:
dir
,
size
:
int64
(
size
),
},
nil
},
nil
}
}
...
@@ -156,7 +158,7 @@ func NewUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (fi
...
@@ -156,7 +158,7 @@ func NewUnixfsFile(ctx context.Context, dserv ipld.DAGService, nd ipld.Node) (fi
return
nil
,
err
return
nil
,
err
}
}
if
fsn
.
IsDir
()
{
if
fsn
.
IsDir
()
{
return
newUnixfsDir
(
ctx
,
dserv
,
n
d
)
return
newUnixfsDir
(
ctx
,
dserv
,
d
n
)
}
}
if
fsn
.
Type
()
==
ft
.
TSymlink
{
if
fsn
.
Type
()
==
ft
.
TSymlink
{
return
files
.
NewLinkFile
(
string
(
fsn
.
Data
()),
nil
),
nil
return
files
.
NewLinkFile
(
string
(
fsn
.
Data
()),
nil
),
nil
...
...
package.json
View file @
323371cb
...
@@ -79,6 +79,6 @@
...
@@ -79,6 +79,6 @@
"license"
:
""
,
"license"
:
""
,
"name"
:
"go-unixfs"
,
"name"
:
"go-unixfs"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"version"
:
"1.3.
0
"
"version"
:
"1.3.
1
"
}
}
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