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
eddd6411
Commit
eddd6411
authored
Sep 06, 2015
by
Matt Bell
Committed by
rht
Oct 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve '/ipfs/root/some/path' paths in 'ipfs resolve' command
License: MIT Signed-off-by:
Matt Bell
<
mappum@gmail.com
>
parent
bea47c9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
core/commands/resolve.go
core/commands/resolve.go
+30
-0
No files found.
core/commands/resolve.go
View file @
eddd6411
...
...
@@ -5,6 +5,7 @@ import (
"strings"
cmds
"github.com/ipfs/go-ipfs/commands"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
namesys
"github.com/ipfs/go-ipfs/namesys"
path
"github.com/ipfs/go-ipfs/path"
u
"github.com/ipfs/go-ipfs/util"
...
...
@@ -78,6 +79,16 @@ Resolve the value of another name recursively:
depth
=
namesys
.
DefaultDepthLimit
}
if
strings
.
HasPrefix
(
name
,
"/ipfs/"
)
||
!
strings
.
HasPrefix
(
name
,
"/"
)
{
resolved
,
err
:=
resolveIpfsPath
(
req
.
Context
(),
n
.
Resolver
,
name
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
res
.
SetOutput
(
&
ResolvedPath
{
resolved
})
return
}
output
,
err
:=
n
.
Namesys
.
ResolveN
(
req
.
Context
(),
name
,
depth
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
...
...
@@ -97,3 +108,22 @@ Resolve the value of another name recursively:
},
Type
:
ResolvedPath
{},
}
func
resolveIpfsPath
(
ctx
context
.
Context
,
r
*
path
.
Resolver
,
name
string
)
(
path
.
Path
,
error
)
{
p
,
err
:=
path
.
ParsePath
(
name
)
if
err
!=
nil
{
return
""
,
err
}
node
,
err
:=
r
.
ResolvePath
(
ctx
,
p
)
if
err
!=
nil
{
return
""
,
err
}
key
,
err
:=
node
.
Key
()
if
err
!=
nil
{
return
""
,
err
}
return
path
.
FromKey
(
key
),
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