@cryptotaxi247 / kubo / commits / 6da12b539

address comments from CR

Jeromy committed Apr 23, 2015 at 22:02 UTC 6da12b53988f0b5bb8530236163751777dceb8b2
3 files changed +11 -6
core/pathresolver.go
+6 -1
@@ -44,7 +44,12 @@ func resolveRecurse(n *IpfsNode, p path.Path, depth int) (*merkledag.Node, error
44 return nil, err
45 }
46
47 - return resolveRecurse(n, path.FromSegments(append(respath.Segments(), extensions...)...), depth+1)
47 + segments := append(respath.Segments(), extensions...)
48 + respath, err = path.FromSegments(segments...)
49 + if err != nil {
50 + return nil, err
51 + }
52 + return resolveRecurse(n, respath, depth+1)
53 }
54
55 // ok, we have an ipfs path now (or what we'll treat as one)
path/path.go
+2 -2
@@ -44,12 +44,12 @@ func (p Path) String() string {
44 return string(p)
45 }
46
47 -func FromSegments(seg ...string) Path {
47 +func FromSegments(seg ...string) (Path, error) {
48 var pref string
49 if seg[0] == "ipfs" || seg[0] == "ipns" {
50 pref = "/"
51 }
52 - return Path(pref + strings.Join(seg, "/"))
52 + return ParsePath(pref + strings.Join(seg, "/"))
53 }
54
55 func ParsePath(txt string) (Path, error) {
test/sharness/t0101-iptb-name.sh
+3 -3
@@ -16,7 +16,7 @@ test_expect_success "set up an iptb cluster" '
16 '
17
18 test_expect_success "add an obect on one node" '
19 - export IPFS_PATH="$IPTB_ROOT/1"
19 + export IPFS_PATH="$IPTB_ROOT/1" &&
20 echo "ipns is super fun" > file &&
21 HASH_FILE=`ipfs add -q file`
22 '
@@ -26,13 +26,13 @@ test_expect_success "publish that object as an ipns entry" '
26 '
27
28 test_expect_success "add an entry on another node pointing to that one" '
29 - export IPFS_PATH="$IPTB_ROOT/2"
29 + export IPFS_PATH="$IPTB_ROOT/2" &&
30 NODE1_ID=`iptb get id 1` &&
31 ipfs name publish /ipns/$NODE1_ID
32 '
33
34 test_expect_success "cat that entry on a third node" '
35 - export IPFS_PATH="$IPTB_ROOT/3"
35 + export IPFS_PATH="$IPTB_ROOT/3" &&
36 NODE2_ID=`iptb get id 2` &&
37 ipfs cat /ipns/$NODE2_ID > output
38 '