Commit 31115f51 authored by rht's avatar rht

Allow `ipfs cat` on ipns path

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 36de29ac
...@@ -31,6 +31,13 @@ it contains. ...@@ -31,6 +31,13 @@ it contains.
return return
} }
if !node.OnlineMode() {
if err := node.SetupOfflineRouting(); err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
}
readers, length, err := cat(req.Context(), node, req.Arguments()) readers, length, err := cat(req.Context(), node, req.Arguments())
if err != nil { if err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
......
...@@ -8,8 +8,7 @@ import ( ...@@ -8,8 +8,7 @@ import (
) )
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) { func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
p := path.FromString(pstr) dagNode, err := core.Resolve(ctx, n, path.Path(pstr))
dagNode, err := n.Resolver.ResolvePath(ctx, p)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -54,6 +54,12 @@ test_expect_success "resolve output looks good" ' ...@@ -54,6 +54,12 @@ test_expect_success "resolve output looks good" '
test_cmp expected4 output test_cmp expected4 output
' '
test_expect_success "ipfs cat on published content succeeds" '
ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected &&
ipfs cat "/ipns/$PEERID" >actual &&
test_cmp expected actual
'
# publish with an explicit node ID # publish with an explicit node ID
test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" ' test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment