Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
57689ffc
提交
57689ffc
authored
11月 15, 2014
作者:
Brian Tiger Chow
提交者:
Juan Batiz-Benet
11月 16, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(2/version) make it possible to execute before init
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
上级
4678dea0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
11 行删除
+17
-11
ipfs.go
cmd/ipfs2/ipfs.go
+16
-10
main.go
cmd/ipfs2/main.go
+1
-1
没有找到文件。
cmd/ipfs2/ipfs.go
浏览文件 @
57689ffc
...
...
@@ -51,18 +51,23 @@ func isLocal(cmd *cmds.Command) bool {
return
found
}
// NB: when necessary, properties are described using negatives in order to
// provide desirable defaults
type
cmdDetails
struct
{
cannotRunOnClient
bool
cannotRunOnDaemon
bool
doesNotUseRepo
bool
// initializesConfig describes commands that initialize the config.
// pre-command hooks that require configs must not be run before this
// command
initializesConfig
bool
// doesNotUseConfigAsInput describes commands that do not use the config as
// input. These commands either initialize the config or perform operations
// that don't require access to the config.
//
// pre-command hooks that require configs must not be run before these
// commands.
doesNotUseConfigAsInput
bool
// preemptsAutoUpdate describes commands that must be executed without the
//
pre-command update
hook
//
auto-update pre-command
hook
preemptsAutoUpdate
bool
}
...
...
@@ -71,21 +76,22 @@ func (d *cmdDetails) String() string {
d
.
canRunOnClient
(),
d
.
canRunOnDaemon
(),
d
.
usesRepo
())
}
func
(
d
*
cmdDetails
)
canRunOnClient
()
bool
{
return
!
d
.
cannotRunOnClient
}
func
(
d
*
cmdDetails
)
canRunOnDaemon
()
bool
{
return
!
d
.
cannotRunOnDaemon
}
func
(
d
*
cmdDetails
)
usesRepo
()
bool
{
return
!
d
.
doesNotUseRepo
}
func
(
d
*
cmdDetails
)
usesConfigAsInput
()
bool
{
return
!
d
.
doesNotUseConfigAsInput
}
func
(
d
*
cmdDetails
)
canRunOnClient
()
bool
{
return
!
d
.
cannotRunOnClient
}
func
(
d
*
cmdDetails
)
canRunOnDaemon
()
bool
{
return
!
d
.
cannotRunOnDaemon
}
func
(
d
*
cmdDetails
)
usesRepo
()
bool
{
return
!
d
.
doesNotUseRepo
}
// "What is this madness!?" you ask. Our commands have the unfortunate problem of
// not being able to run on all the same contexts. This map describes these
// properties so that other code can make decisions about whether to invoke a
// command or return an error to the user.
var
cmdDetailsMap
=
map
[
*
cmds
.
Command
]
cmdDetails
{
initCmd
:
cmdDetails
{
initializesConfig
:
true
,
cannotRunOnDaemon
:
true
,
doesNotUseRepo
:
true
},
initCmd
:
cmdDetails
{
doesNotUseConfigAsInput
:
true
,
cannotRunOnDaemon
:
true
,
doesNotUseRepo
:
true
},
daemonCmd
:
cmdDetails
{
cannotRunOnDaemon
:
true
},
commandsClientCmd
:
cmdDetails
{
doesNotUseRepo
:
true
},
commands
.
CommandsDaemonCmd
:
cmdDetails
{
doesNotUseRepo
:
true
},
commands
.
DiagCmd
:
cmdDetails
{
cannotRunOnClient
:
true
},
commands
.
VersionCmd
:
cmdDetails
{
doesNotUse
Repo
:
true
},
commands
.
VersionCmd
:
cmdDetails
{
doesNotUse
ConfigAsInput
:
true
,
doesNotUseRepo
:
true
},
// must be permitted to run before init
commands
.
UpdateCmd
:
cmdDetails
{
preemptsAutoUpdate
:
true
,
cannotRunOnDaemon
:
true
},
commands
.
UpdateCheckCmd
:
cmdDetails
{
preemptsAutoUpdate
:
true
},
commands
.
UpdateLogCmd
:
cmdDetails
{
preemptsAutoUpdate
:
true
},
...
...
cmd/ipfs2/main.go
浏览文件 @
57689ffc
...
...
@@ -217,7 +217,7 @@ func callPreCommandHooks(details cmdDetails, req cmds.Request, root *cmds.Comman
// check for updates when 1) commands is going to be run locally, 2) the
// command does not initialize the config, and 3) the command does not
// pre-empt updates
if
!
daemon
&&
!
details
.
initializesConfig
&&
!
details
.
preemptsAutoUpdate
{
if
!
daemon
&&
details
.
usesConfigAsInput
()
&&
!
details
.
preemptsAutoUpdate
{
log
.
Debug
(
"Calling hook: Check for updates"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论