提交 9ab67a38 作者: Jeromy Johnson

Merge pull request #2323 from noffle/no_publish_while_mounted

Prevents 'ipfs name publish' when /ipns is mounted.
......@@ -74,6 +74,11 @@ Publish an <ipfs-path> to another public key (not implemented):
}
}
if n.Mounts.Ipns != nil && n.Mounts.Ipns.IsActive() {
res.SetError(errors.New("You cannot manually publish while IPNS is mounted."), cmds.ErrNormal)
return
}
pstr := req.Arguments()[0]
if n.Identity == "" {
......
......@@ -151,10 +151,7 @@ func TestIpnsLocalLink(t *testing.T) {
defer mnt.Close()
name := mnt.Dir + "/local"
_, err := os.Stat(name)
if err != nil {
t.Fatal(err)
}
checkExists(t, name)
linksto, err := os.Readlink(name)
if err != nil {
......
#!/bin/sh
test_description="Test mount command in conjunction with publishing"
# imports
. lib/test-lib.sh
# if in travis CI, dont test mount (no fuse)
if ! test_have_prereq FUSE; then
skip_all='skipping mount tests, fuse not available'
test_done
fi
test_init_ipfs
# start iptb + wait for peering
NUM_NODES=3
test_expect_success 'init iptb' '
iptb init -n $NUM_NODES -f --bootstrap=none --port=0 &&
startup_cluster $NUM_NODES
'
# pre-mount publish
HASH=$(echo 'hello warld' | ipfsi 0 add -q)
test_expect_success "can publish before mounting /ipns" '
ipfsi 0 name publish '$HASH'
'
# mount
IPFS_MOUNT_DIR="$PWD/ipfs"
IPNS_MOUNT_DIR="$PWD/ipns"
test_expect_success FUSE "'ipfs mount' succeeds" '
ipfsi 0 mount -f "'"$IPFS_MOUNT_DIR"'" -n "'"$IPNS_MOUNT_DIR"'" >actual
'
test_expect_success FUSE "'ipfs mount' output looks good" '
echo "IPFS mounted at: $PWD/ipfs" >expected &&
echo "IPNS mounted at: $PWD/ipns" >>expected &&
test_cmp expected actual
'
test_expect_success "cannot publish after mounting /ipns" '
echo "Error: You cannot manually publish while IPNS is mounted." >expected &&
test_must_fail ipfsi 0 name publish '$HASH' 2>actual &&
test_cmp expected actual
'
test_expect_success "unmount /ipns out-of-band" '
fusermount -u "'"$IPNS_MOUNT_DIR"'"
'
test_expect_success "can publish after unmounting /ipns" '
ipfsi 0 name publish '$HASH'
'
# clean-up ipfs
test_expect_success "unmount /ipfs" '
fusermount -u "'"$IPFS_MOUNT_DIR"'"
'
iptb stop
test_done
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论