提交 dc303d06 作者: Steven Allen

cmds(repo rm-root): bring --remove-existing-root in-line with it's documentation

This command is already annoying enough. If a user decides to automate this,
that's their issue (and we should allow it).

(also rename back to remove-existing-root from remove-local-root)

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 03e79f47
...@@ -286,11 +286,11 @@ This command can only run when the ipfs daemon is not running. ...@@ -286,11 +286,11 @@ This command can only run when the ipfs daemon is not running.
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("confirm", "Really perform operation."), cmdkit.BoolOption("confirm", "Really perform operation."),
cmdkit.BoolOption("remove-local-root", "Remove even if the root exists locally."), cmdkit.BoolOption("remove-existing-root", "Remove even if it root exists locally."),
}, },
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
confirm, _ := req.Options["confirm"].(bool) confirm, _ := req.Options["confirm"].(bool)
removeLocalRoot, _ := req.Options["remove-local-root"].(bool) removeExistingRoot, _ := req.Options["remove-existing-root"].(bool)
if !confirm { if !confirm {
return fmt.Errorf("this is a potentially dangerous operation please pass --confirm to proceed") return fmt.Errorf("this is a potentially dangerous operation please pass --confirm to proceed")
...@@ -328,10 +328,8 @@ This command can only run when the ipfs daemon is not running. ...@@ -328,10 +328,8 @@ This command can only run when the ipfs daemon is not running.
cidStr = b58.Encode(val) cidStr = b58.Encode(val)
} }
if have && !removeLocalRoot { if have && !removeExistingRoot {
return fmt.Errorf("root %s exists locally. Are you sure you want to unlink this? Pass --remove-local-root to continue", cidStr) return fmt.Errorf("root %s exists locally. Are you sure you want to unlink this? Pass --remove-existing-root to continue", cidStr)
} else if !have && removeLocalRoot {
return fmt.Errorf("root does not %s exists locally. Please remove --remove-local-root to continue", cidStr)
} }
err = repo.Datastore().Delete(core.FilesRootKey) err = repo.Datastore().Delete(core.FilesRootKey)
......
...@@ -18,14 +18,14 @@ test_expect_success "ipfs repo rm-root fails without --confirm" ' ...@@ -18,14 +18,14 @@ test_expect_success "ipfs repo rm-root fails without --confirm" '
fgrep -q "please pass --confirm to proceed" err fgrep -q "please pass --confirm to proceed" err
' '
test_expect_success "ipfs repo rm-root fails to remove existing root without --remove-local-root" ' test_expect_success "ipfs repo rm-root fails to remove existing root without --remove-existing-root" '
test_must_fail ipfs repo rm-root --confirm 2> err && test_must_fail ipfs repo rm-root --confirm 2> err &&
cat err && cat err &&
fgrep -q "Are you sure you want to unlink this?" err fgrep -q "Are you sure you want to unlink this?" err
' '
test_expect_success "ipfs repo rm-root" ' test_expect_success "ipfs repo rm-root" '
ipfs repo rm-root --confirm --remove-local-root | tee rm-root.actual && ipfs repo rm-root --confirm --remove-existing-root | tee rm-root.actual &&
echo "Unlinked files API root. Root hash was $ROOT_HASH." > rm-root.expected && echo "Unlinked files API root. Root hash was $ROOT_HASH." > rm-root.expected &&
test_cmp rm-root.expected rm-root.actual test_cmp rm-root.expected rm-root.actual
' '
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论