提交 784e0d8e 作者: Steven Allen

cmds(ipfs rm-files-root): improve language around rm-root command

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 dc303d06
......@@ -84,14 +84,14 @@ func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
// properties so that other code can make decisions about whether to invoke a
// command or return an error to the user.
var cmdDetailsMap = map[string]cmdDetails{
"init": {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true, doesNotUseRepo: true},
"daemon": {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true},
"commands": {doesNotUseRepo: true},
"version": {doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init
"log": {cannotRunOnClient: true},
"diag/cmds": {cannotRunOnClient: true},
"repo/fsck": {cannotRunOnDaemon: true},
"repo/rm-root": {cannotRunOnDaemon: true},
"config/edit": {cannotRunOnDaemon: true, doesNotUseRepo: true},
"cid": {doesNotUseRepo: true},
"init": {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true, doesNotUseRepo: true},
"daemon": {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true},
"commands": {doesNotUseRepo: true},
"version": {doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init
"log": {cannotRunOnClient: true},
"diag/cmds": {cannotRunOnClient: true},
"repo/fsck": {cannotRunOnDaemon: true},
"repo/rm-files-root": {cannotRunOnDaemon: true},
"config/edit": {cannotRunOnDaemon: true, doesNotUseRepo: true},
"cid": {doesNotUseRepo: true},
}
......@@ -188,7 +188,7 @@ func TestCommands(t *testing.T) {
"/repo/stat",
"/repo/verify",
"/repo/version",
"/repo/rm-root",
"/repo/rm-files-root",
"/resolve",
"/shutdown",
"/stats",
......
......@@ -39,12 +39,12 @@ var RepoCmd = &cmds.Command{
},
Subcommands: map[string]*cmds.Command{
"stat": repoStatCmd,
"gc": repoGcCmd,
"fsck": repoFsckCmd,
"version": repoVersionCmd,
"verify": repoVerifyCmd,
"rm-root": repoRmRootCmd,
"stat": repoStatCmd,
"gc": repoGcCmd,
"fsck": repoFsckCmd,
"version": repoVersionCmd,
"verify": repoVerifyCmd,
"rm-files-root": repoRmFilesRootCmd,
},
}
......@@ -266,11 +266,11 @@ daemons are running.
},
}
var repoRmRootCmd = &cmds.Command{
var repoRmFilesRootCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Unlink the root used by the files API.",
Tagline: "Unlink the root used by the `ipfs files` comands.",
ShortDescription: `
'ipfs repo rm-root' will unlink the root used by the files API ('ipfs
'ipfs repo rm-files-root' will unlink the root used by the files API ('ipfs
files' commands) without trying to read the root itself. The root and
its children will be removed the next time the garbage collector runs,
unless pinned.
......@@ -315,7 +315,7 @@ This command can only run when the ipfs daemon is not running.
// such as pin it
val, err := repo.Datastore().Get(core.FilesRootKey)
if err == ds.ErrNotFound || val == nil {
return cmds.EmitOnce(res, &MessageOutput{"Files API root not found.\n"})
return cmds.EmitOnce(res, &MessageOutput{"`ipfs files` root not found.\n"})
}
var cidStr string
......@@ -329,12 +329,12 @@ This command can only run when the ipfs daemon is not running.
}
if have && !removeExistingRoot {
return fmt.Errorf("root %s exists locally. Are you sure you want to unlink this? Pass --remove-existing-root to continue", cidStr)
return fmt.Errorf("`ipfs files` root %s exists locally. Are you sure you want to unlink this? Pass --remove-existing-root to continue", cidStr)
}
err = repo.Datastore().Delete(core.FilesRootKey)
if err != nil {
return fmt.Errorf("unable to remove API root: %s. Root hash was %s", err.Error(), cidStr)
return fmt.Errorf("unable to remove `ipfs files` root: %s. Root hash was %s", err.Error(), cidStr)
}
return cmds.EmitOnce(res, &MessageOutput{
fmt.Sprintf("Unlinked files API root. Root hash was %s.\n", cidStr),
......
......@@ -12,34 +12,34 @@ test_init_ipfs
ROOT_HASH=QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
test_expect_success "ipfs repo rm-root fails without --confirm" '
test_must_fail ipfs repo rm-root 2> err &&
test_expect_success "ipfs repo rm-files-root fails without --confirm" '
test_must_fail ipfs repo rm-files-root 2> err &&
cat err &&
fgrep -q "please pass --confirm to proceed" err
'
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_expect_success "ipfs repo rm-files-root fails to remove existing root without --remove-existing-root" '
test_must_fail ipfs repo rm-files-root --confirm 2> err &&
cat err &&
fgrep -q "Are you sure you want to unlink this?" err
'
test_expect_success "ipfs repo rm-root" '
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 &&
test_cmp rm-root.expected rm-root.actual
test_expect_success "ipfs repo rm-files-root" '
ipfs repo rm-files-root --confirm --remove-existing-root | tee rm-files-root.actual &&
echo "Unlinked files API root. Root hash was $ROOT_HASH." > rm-files-root.expected &&
test_cmp rm-files-root.expected rm-files-root.actual
'
test_expect_success "files api root really removed" '
ipfs repo rm-root --confirm | tee rm-root-post.actual &&
echo "Files API root not found." > rm-root-post.expected &&
test_cmp rm-root-post.expected rm-root-post.actual
ipfs repo rm-files-root --confirm | tee rm-files-root-post.actual &&
echo "Files API root not found." > rm-files-root-post.expected &&
test_cmp rm-files-root-post.expected rm-files-root-post.actual
'
test_launch_ipfs_daemon
test_expect_success "ipfs repo rm-root does not run on daemon" '
test_must_fail ipfs repo rm-root --confirm 2> err &&
test_expect_success "ipfs repo rm-files-root does not run on daemon" '
test_must_fail ipfs repo rm-files-root --confirm 2> err &&
cat err &&
fgrep -q "ipfs daemon is running" err
'
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论