Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
784e0d8e
提交
784e0d8e
authored
3月 04, 2019
作者:
Steven Allen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmds(ipfs rm-files-root): improve language around rm-root command
License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
上级
dc303d06
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
36 行删除
+36
-36
ipfs.go
cmd/ipfs/ipfs.go
+10
-10
commands_test.go
core/commands/commands_test.go
+1
-1
repo.go
core/commands/repo.go
+12
-12
t0089-repo-rm-files-root.sh
test/sharness/t0089-repo-rm-files-root.sh
+13
-13
没有找到文件。
cmd/ipfs/ipfs.go
浏览文件 @
784e0d8e
...
...
@@ -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
},
}
core/commands/commands_test.go
浏览文件 @
784e0d8e
...
...
@@ -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"
,
...
...
core/commands/repo.go
浏览文件 @
784e0d8e
...
...
@@ -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"
:
repoRm
RootCmd
,
"stat"
:
repoStatCmd
,
"gc"
:
repoGcCmd
,
"fsck"
:
repoFsckCmd
,
"version"
:
repoVersionCmd
,
"verify"
:
repoVerifyCmd
,
"rm-
files-root"
:
repoRmFiles
RootCmd
,
},
}
...
...
@@ -266,11 +266,11 @@ daemons are running.
},
}
var
repoRmRootCmd
=
&
cmds
.
Command
{
var
repoRm
Files
RootCmd
=
&
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
),
...
...
test/sharness/t0089-repo-rm-root.sh
→
test/sharness/t0089-repo-rm-
files-
root.sh
浏览文件 @
784e0d8e
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论