Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
37673c85
提交
37673c85
authored
7月 06, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a test for auto migrations cli interface
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
cc73137f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
62 行增加
和
3 行删除
+62
-3
daemon.go
cmd/ipfs/daemon.go
+1
-0
mfsr.go
repo/fsrepo/migrations/mfsr.go
+6
-2
migrations.go
repo/fsrepo/migrations/migrations.go
+3
-1
t0066-migration.sh
test/sharness/t0066-migration.sh
+52
-0
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
37673c85
...
...
@@ -225,6 +225,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
return
case
fsrepo
.
ErrNeedMigration
:
domigrate
,
found
,
_
:=
req
.
Option
(
migrateKwd
)
.
Bool
()
fmt
.
Println
(
"Found old repo version, migrations need to be run."
)
if
!
found
{
err
=
migrate
.
TryMigrating
(
fsrepo
.
RepoVersion
)
...
...
repo/fsrepo/migrations/mfsr.go
浏览文件 @
37673c85
...
...
@@ -61,7 +61,7 @@ func (v VersionFileNotFound) Error() string {
}
func
TryMigrating
(
tovers
int
)
error
{
if
!
YesNoPrompt
(
"
run migrations automatically? [y/n
]"
)
{
if
!
YesNoPrompt
(
"
Run migrations automatically? [y/N
]"
)
{
return
fmt
.
Errorf
(
"please run the migrations manually"
)
}
...
...
@@ -70,7 +70,7 @@ func TryMigrating(tovers int) error {
func
YesNoPrompt
(
prompt
string
)
bool
{
var
s
string
for
{
for
i
:=
0
;
i
<
3
;
i
++
{
fmt
.
Printf
(
"%s "
,
prompt
)
fmt
.
Scanf
(
"%s"
,
&
s
)
switch
s
{
...
...
@@ -78,7 +78,11 @@ func YesNoPrompt(prompt string) bool {
return
true
case
"n"
,
"N"
:
return
false
case
""
:
return
false
}
fmt
.
Println
(
"Please press either 'y' or 'n'"
)
}
return
false
}
repo/fsrepo/migrations/migrations.go
浏览文件 @
37673c85
...
...
@@ -27,7 +27,9 @@ const migrations = "fs-repo-migrations"
func
RunMigration
(
newv
int
)
error
{
migrateBin
:=
"fs-repo-migrations"
fmt
.
Println
(
" => checking for migrations binary..."
)
_
,
err
:=
exec
.
LookPath
(
migrateBin
)
var
err
error
migrateBin
,
err
=
exec
.
LookPath
(
migrateBin
)
if
err
==
nil
{
// check to make sure migrations binary supports our target version
err
=
verifyMigrationSupportsVersion
(
migrateBin
,
newv
)
...
...
test/sharness/t0066-migration.sh
0 → 100755
浏览文件 @
37673c85
#!/bin/sh
#
# Copyright (c) 2016 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test migrations auto update prompt"
.
lib/test-lib.sh
test_init_ipfs
test_expect_success
"setup mock migrations"
'
mkdir bin &&
echo "#!/bin/bash" > bin/fs-repo-migrations &&
echo "echo 4" >> bin/fs-repo-migrations &&
chmod +x bin/fs-repo-migrations &&
export PATH="$(pwd)/bin":$PATH
'
test_expect_success
"manually reset repo version to 3"
'
echo "3" > "$IPFS_PATH"/version
'
test_expect_success
"ipfs daemon --migrate=false fails"
'
test_expect_code 1 ipfs daemon --migrate=false 2> false_out
'
test_expect_success
"output looks good"
'
grep "ipfs repo needs migration" false_out
'
test_expect_success
"ipfs daemon --migrate=true runs migration"
'
test_expect_code 1 ipfs daemon --migrate=true > true_out
'
test_expect_success
"output looks good"
'
grep "running migration" true_out > /dev/null &&
grep "binary completed successfully" true_out > /dev/null
'
test_expect_success
"'ipfs daemon' prompts to auto migrate"
'
test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err
'
test_expect_success
"output looks good"
'
grep "Found old repo version" daemon_out > /dev/null &&
grep "Run migrations automatically?" daemon_out > /dev/null &&
grep "please run the migrations manually" daemon_err > /dev/null
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论