fix offline full path resolution bug
Jeromy committed
May 21, 2015 at 14:26 UTC
60ac59139c1a446bf2051c1a6ab5db4805129dc4
2 files changed
+37
-2
core/pathresolver.go
+3
-2
@@ -20,8 +20,9 @@ var ErrNoNamesys = errors.New(
20
// entries and returning the final merkledage node. Effectively
21
// enables /ipns/, /dns/, etc. in commands.
22
func Resolve(ctx context.Context, n *IpfsNode, p path.Path) (*merkledag.Node, error) {
23
- if strings.HasPrefix(p.String(), "/") {
24
- // namespaced path (/ipfs/..., /ipns/..., etc.)
23
+ if strings.HasPrefix(p.String(), "/ipns/") {
24
+ // resolve ipns paths
25
+
26
// TODO(cryptix): we sould be able to query the local cache for the path
27
if n.Namesys == nil {
28
return nil, ErrNoNamesys
test/sharness/t0041-add-cat-offline.sh
new
+34
@@ -0,0 +1,34 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2014 Jeromy Johnson
4
+# MIT Licensed; see the LICENSE file in this repository.
5
+#
6
+
7
+test_description="Test add and cat commands"
8
+
9
+. lib/test-lib.sh
10
+
11
+test_init_ipfs
12
+
13
+test_expect_success "ipfs add file succeeds" '
14
+ echo "some content" > afile &&
15
+ HASH=$(ipfs add -q afile)
16
+'
17
+
18
+test_expect_success "ipfs cat file suceeds" '
19
+ ipfs cat $HASH > out_1
20
+'
21
+
22
+test_expect_success "output looks good" '
23
+ test_cmp afile out_1
24
+'
25
+
26
+test_expect_success "ipfs cat /ipfs/file succeeds" '
27
+ ipfs cat /ipfs/$HASH > out_2
28
+'
29
+
30
+test_expect_success "output looks good" '
31
+ test_cmp afile out_2
32
+'
33
+
34
+test_done