mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 02:30:39 +08:00
address comments from CR
This commit is contained in:
@ -44,7 +44,12 @@ func resolveRecurse(n *IpfsNode, p path.Path, depth int) (*merkledag.Node, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolveRecurse(n, path.FromSegments(append(respath.Segments(), extensions...)...), depth+1)
|
segments := append(respath.Segments(), extensions...)
|
||||||
|
respath, err = path.FromSegments(segments...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resolveRecurse(n, respath, depth+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, we have an ipfs path now (or what we'll treat as one)
|
// ok, we have an ipfs path now (or what we'll treat as one)
|
||||||
|
@ -44,12 +44,12 @@ func (p Path) String() string {
|
|||||||
return string(p)
|
return string(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSegments(seg ...string) Path {
|
func FromSegments(seg ...string) (Path, error) {
|
||||||
var pref string
|
var pref string
|
||||||
if seg[0] == "ipfs" || seg[0] == "ipns" {
|
if seg[0] == "ipfs" || seg[0] == "ipns" {
|
||||||
pref = "/"
|
pref = "/"
|
||||||
}
|
}
|
||||||
return Path(pref + strings.Join(seg, "/"))
|
return ParsePath(pref + strings.Join(seg, "/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParsePath(txt string) (Path, error) {
|
func ParsePath(txt string) (Path, error) {
|
||||||
|
@ -16,7 +16,7 @@ test_expect_success "set up an iptb cluster" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "add an obect on one node" '
|
test_expect_success "add an obect on one node" '
|
||||||
export IPFS_PATH="$IPTB_ROOT/1"
|
export IPFS_PATH="$IPTB_ROOT/1" &&
|
||||||
echo "ipns is super fun" > file &&
|
echo "ipns is super fun" > file &&
|
||||||
HASH_FILE=`ipfs add -q file`
|
HASH_FILE=`ipfs add -q file`
|
||||||
'
|
'
|
||||||
@ -26,13 +26,13 @@ test_expect_success "publish that object as an ipns entry" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "add an entry on another node pointing to that one" '
|
test_expect_success "add an entry on another node pointing to that one" '
|
||||||
export IPFS_PATH="$IPTB_ROOT/2"
|
export IPFS_PATH="$IPTB_ROOT/2" &&
|
||||||
NODE1_ID=`iptb get id 1` &&
|
NODE1_ID=`iptb get id 1` &&
|
||||||
ipfs name publish /ipns/$NODE1_ID
|
ipfs name publish /ipns/$NODE1_ID
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "cat that entry on a third node" '
|
test_expect_success "cat that entry on a third node" '
|
||||||
export IPFS_PATH="$IPTB_ROOT/3"
|
export IPFS_PATH="$IPTB_ROOT/3" &&
|
||||||
NODE2_ID=`iptb get id 2` &&
|
NODE2_ID=`iptb get id 2` &&
|
||||||
ipfs cat /ipns/$NODE2_ID > output
|
ipfs cat /ipns/$NODE2_ID > output
|
||||||
'
|
'
|
||||||
|
Reference in New Issue
Block a user