Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents 'ipfs name publish' when /ipns is mounted. #2323

Merged
merged 4 commits into from
Mar 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/commands/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
5 changes: 1 addition & 4 deletions fuse/ipns/ipns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/lib/iptb-lib.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# iptb test framework
# iptb test framework
#
# Copyright (c) 2014, 2016 Jeromy Johnson, Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
Expand Down
62 changes: 62 additions & 0 deletions test/sharness/t0031-mount-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/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
12 changes: 6 additions & 6 deletions test/sharness/t0045-ls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ test_ls_cmd() {
QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2

QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a

QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a

EOF
test_cmp expected_ls actual_ls
'
Expand All @@ -74,17 +74,17 @@ test_ls_cmd() {
QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/
QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1
QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2

QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy:
Hash Size Name
QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024
QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a

QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss:
Hash Size Name
QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128
QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a

EOF
test_cmp expected_ls_headers actual_ls_headers
'
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0121-bootstrap-iptb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test_expect_success "bring down iptb nodes" '
PID4=$(cat "$IPTB_ROOT/4/daemon.pid") &&
iptb stop && # TODO: add --wait flag to iptb stop
betterwait $PID0
betterwait $PID1
betterwait $PID1
betterwait $PID2
betterwait $PID3
betterwait $PID4
Expand Down