Skip to content

Commit

Permalink
fix: correctly trim resolved IPNS addresses
Browse files Browse the repository at this point in the history
fixes #7246
  • Loading branch information
Stebalien committed May 20, 2020
1 parent 1744eb2 commit 391d345
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
return nil, errors.New("invalid path from ipns record")
}

return &Link{s.IpfsRoot + "/" + strings.TrimPrefix("/ipfs/", resolved.String())}, nil
return &Link{s.IpfsRoot + "/" + strings.TrimPrefix(resolved.String(), "/ipfs/")}, nil
}

func (r *Root) Close() error {
Expand Down
10 changes: 9 additions & 1 deletion test/sharness/t0030-mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ if ! test_have_prereq FUSE; then
test_done
fi


export IPFS_NS_MAP="welcome.example.com:/ipfs/$HASH_WELCOME_DOCS"

# start iptb + wait for peering
NUM_NODES=5
test_expect_success 'init iptb' '
iptb testbed create -type localipfs -count $NUM_NODES -init
'
startup_cluster $NUM_NODES


# test mount failure before mounting properly.
test_expect_success "'ipfs mount' fails when there is no mount dir" '
tmp_ipfs_mount() { ipfsi 0 mount -f=not_ipfs -n=not_ipns >output 2>output.err; } &&
Expand Down Expand Up @@ -53,6 +55,12 @@ test_expect_success FUSE "'ipfs mount' output looks good" '
test_cmp expected actual
'

test_expect_success FUSE "can resolve ipns names" '
echo -n "ipfs" > expected &&
cat ipns/welcome.example.com/ping > actual &&
test_cmp expected actual
'

test_expect_success "mount directories cannot be removed while active" '
test_must_fail rmdir ipfs ipns 2>/dev/null
'
Expand Down

0 comments on commit 391d345

Please sign in to comment.