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
2c0bb93a
Unverified
Commit
2c0bb93a
authored
Mar 22, 2018
by
Whyrusleeping
Committed by
GitHub
Mar 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4844 from ipfs/fix/4800
fix(mfs): Directory.Path not working, add test
parents
036d3bda
48f706b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
mfs/dir.go
mfs/dir.go
+9
-2
mfs/mfs_test.go
mfs/mfs_test.go
+5
-0
No files found.
mfs/dir.go
View file @
2c0bb93a
...
...
@@ -404,8 +404,15 @@ func (d *Directory) Path() string {
cur
:=
d
var
out
string
for
cur
!=
nil
{
out
=
path
.
Join
(
cur
.
name
,
out
)
cur
=
cur
.
parent
.
(
*
Directory
)
switch
parent
:=
cur
.
parent
.
(
type
)
{
case
*
Directory
:
out
=
path
.
Join
(
cur
.
name
,
out
)
cur
=
parent
case
*
Root
:
return
"/"
+
out
default
:
panic
(
"directory parent neither a directory nor a root"
)
}
}
return
out
}
...
...
mfs/mfs_test.go
View file @
2c0bb93a
...
...
@@ -324,6 +324,11 @@ func TestDirectoryLoadFromDag(t *testing.T) {
topd
:=
topi
.
(
*
Directory
)
path
:=
topd
.
Path
()
if
path
!=
"/foo"
{
t
.
Fatalf
(
"Expected path '/foo', got '%s'"
,
path
)
}
// mkdir over existing but unloaded child file should fail
_
,
err
=
topd
.
Mkdir
(
"a"
)
if
err
==
nil
{
...
...
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