From 391d345622e055c9b1b9bd272aabd4a2f61a9002 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 19 May 2020 17:38:18 -0700 Subject: [PATCH] fix: correctly trim resolved IPNS addresses fixes https://github.com/ipfs/go-ipfs/issues/7246 --- fuse/ipns/ipns_unix.go | 2 +- test/sharness/t0030-mount.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index 64233a3be..fa65c51c4 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -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 { diff --git a/test/sharness/t0030-mount.sh b/test/sharness/t0030-mount.sh index 4282083ee..a23fd1602 100755 --- a/test/sharness/t0030-mount.sh +++ b/test/sharness/t0030-mount.sh @@ -15,6 +15,9 @@ 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' ' @@ -22,7 +25,6 @@ test_expect_success 'init iptb' ' ' 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; } && @@ -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 '