Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
0ff9b24a
提交
0ff9b24a
authored
12月 15, 2017
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
config-patch: backup config
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
2514c747
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
48 行增加
和
0 行删除
+48
-0
config.go
core/commands/config.go
+5
-0
fsrepo.go
repo/fsrepo/fsrepo.go
+26
-0
mock.go
repo/mock.go
+4
-0
repo.go
repo/repo.go
+1
-0
t0021-config.sh
test/sharness/t0021-config.sh
+12
-0
没有找到文件。
core/commands/config.go
浏览文件 @
0ff9b24a
...
...
@@ -372,6 +372,11 @@ func transformConfig(configRoot string, transformer config.Transformer) error {
return
err
}
_
,
err
=
r
.
BackupConfig
(
"profile-"
)
if
err
!=
nil
{
return
err
}
return
r
.
SetConfig
(
cfg
)
}
...
...
repo/fsrepo/fsrepo.go
浏览文件 @
0ff9b24a
...
...
@@ -480,6 +480,32 @@ func (r *FSRepo) FileManager() *filestore.FileManager {
return
r
.
filemgr
}
func
(
r
*
FSRepo
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
{
temp
,
err
:=
ioutil
.
TempFile
(
r
.
path
,
"config-"
+
prefix
)
if
err
!=
nil
{
return
""
,
err
}
defer
temp
.
Close
()
configFilename
,
err
:=
config
.
Filename
(
r
.
path
)
if
err
!=
nil
{
return
""
,
err
}
orig
,
err
:=
os
.
OpenFile
(
configFilename
,
os
.
O_RDONLY
,
0600
)
if
err
!=
nil
{
return
""
,
err
}
defer
orig
.
Close
()
_
,
err
=
io
.
Copy
(
temp
,
orig
)
if
err
!=
nil
{
return
""
,
err
}
return
orig
.
Name
(),
nil
}
// setConfigUnsynced is for private use.
func
(
r
*
FSRepo
)
setConfigUnsynced
(
updated
*
config
.
Config
)
error
{
configFilename
,
err
:=
config
.
Filename
(
r
.
path
)
...
...
repo/mock.go
浏览文件 @
0ff9b24a
...
...
@@ -28,6 +28,10 @@ func (m *Mock) SetConfig(updated *config.Config) error {
return
nil
}
func
(
m
*
Mock
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
{
return
""
,
errTODO
}
func
(
m
*
Mock
)
SetConfigKey
(
key
string
,
value
interface
{})
error
{
return
errTODO
}
...
...
repo/repo.go
浏览文件 @
0ff9b24a
...
...
@@ -18,6 +18,7 @@ var (
type
Repo
interface
{
Config
()
(
*
config
.
Config
,
error
)
BackupConfig
(
prefix
string
)
(
string
,
error
)
SetConfig
(
*
config
.
Config
)
error
SetConfigKey
(
key
string
,
value
interface
{})
error
...
...
test/sharness/t0021-config.sh
浏览文件 @
0ff9b24a
...
...
@@ -183,10 +183,18 @@ test_config_cmd() {
test $(cat actual_config | wc -l) = 1
'
test_expect_success
"copy ipfs config"
'
cp "$IPFS_PATH/config" before_patch
'
test_expect_success
"'ipfs config profile apply server' works"
'
ipfs config profile apply server
'
test_expect_success
"backup was created and looks good"
'
test_cmp "$(find "$IPFS_PATH" -name "config-profile*")" before_patch
'
test_expect_success
"'ipfs config Swarm.AddrFilters' looks good with server profile"
'
ipfs config Swarm.AddrFilters > actual_config &&
test $(cat actual_config | wc -l) = 17
...
...
@@ -209,6 +217,10 @@ test_config_cmd() {
# won't work as it changes datastore definition, which makes ipfs not launch
# without converting first
# test_profile_apply_revert badgerds
test_expect_success
"cleanup config backups"
'
find "$IPFS_PATH" -name "config-profile*" -exec rm {} \;
'
}
test_init_ipfs
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论