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-dms3
Commits
06e71033
Commit
06e71033
authored
9 years ago
by
Stephen Whitmore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache files/dirs when added.
License: MIT Signed-off-by:
Stephen Whitmore
<
noffle@ipfs.io
>
parent
dfd98f27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
mfs/dir.go
mfs/dir.go
+16
-0
No files found.
mfs/dir.go
View file @
06e71033
...
...
@@ -116,6 +116,11 @@ func (d *Directory) childNode(name string) (FSNode, error) {
return
nil
,
err
}
return
d
.
cacheNode
(
name
,
nd
)
}
// cacheNode caches a node into d.childDirs or d.files and returns the FSNode.
func
(
d
*
Directory
)
cacheNode
(
name
string
,
nd
*
dag
.
Node
)
(
FSNode
,
error
)
{
i
,
err
:=
ft
.
FromBytes
(
nd
.
Data
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -334,6 +339,17 @@ func (d *Directory) AddChild(name string, nd *dag.Node) error {
d
.
modTime
=
time
.
Now
()
if
len
(
nd
.
Links
)
==
0
{
nfi
,
err
:=
NewFile
(
name
,
nd
,
d
,
d
.
dserv
)
if
err
!=
nil
{
return
err
}
d
.
files
[
name
]
=
nfi
}
else
{
ndir
:=
NewDirectory
(
d
.
ctx
,
name
,
nd
,
d
,
d
.
dserv
)
d
.
childDirs
[
name
]
=
ndir
}
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
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