Allow `ipfs cat` on ipns path
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
rht committed
Oct 31, 2015 at 10:48 UTC
31115f51a0fe623bdaced276c5abb6ec19330040
3 files changed
+14
-2
core/commands/cat.go
+7
@@ -31,6 +31,13 @@ it contains.
31
return
32
}
33
34
+ if !node.OnlineMode() {
35
+ if err := node.SetupOfflineRouting(); err != nil {
36
+ res.SetError(err, cmds.ErrNormal)
37
+ return
38
+ }
39
+ }
40
+
41
readers, length, err := cat(req.Context(), node, req.Arguments())
42
if err != nil {
43
res.SetError(err, cmds.ErrNormal)
core/coreunix/cat.go
+1
-2
@@ -8,8 +8,7 @@ import (
8
)
9
10
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
11
- p := path.FromString(pstr)
12
- dagNode, err := n.Resolver.ResolvePath(ctx, p)
11
+ dagNode, err := core.Resolve(ctx, n, path.Path(pstr))
12
if err != nil {
13
return nil, err
14
}
test/sharness/t0100-name.sh
+6
@@ -54,6 +54,12 @@ test_expect_success "resolve output looks good" '
54
test_cmp expected4 output
55
'
56
57
+test_expect_success "ipfs cat on published content succeeds" '
58
+ ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected &&
59
+ ipfs cat "/ipns/$PEERID" >actual &&
60
+ test_cmp expected actual
61
+'
62
+
63
# publish with an explicit node ID
64
65
test_expect_failure "'ipfs name publish <local-id> <hash>' succeeds" '