Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7ad559b8
提交
7ad559b8
authored
1月 14, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(fsrepo, component): expose SetPath to ensure that components handle paths
上级
b6603051
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
12 行增加
和
6 行删除
+12
-6
component.go
repo/fsrepo/component/component.go
+1
-0
config.go
repo/fsrepo/component/config.go
+9
-5
fsrepo.go
repo/fsrepo/fsrepo.go
+2
-1
没有找到文件。
repo/fsrepo/component/component.go
浏览文件 @
7ad559b8
...
...
@@ -9,6 +9,7 @@ import (
type
Component
interface
{
Open
()
error
io
.
Closer
SetPath
(
string
)
}
type
Initializer
func
(
path
string
,
conf
*
config
.
Config
)
error
type
InitializationChecker
func
(
path
string
)
bool
repo/fsrepo/component/config.go
浏览文件 @
7ad559b8
...
...
@@ -15,7 +15,7 @@ var _ InitializationChecker = ConfigComponentIsInitialized
// NB: create with makeConfigComponent function.
// NOT THREAD-SAFE
type
ConfigComponent
struct
{
P
ath
string
// required at instantiation
p
ath
string
// required at instantiation
config
*
config
.
Config
// assigned on Open()
}
...
...
@@ -39,7 +39,7 @@ func InitConfigComponent(path string, conf *config.Config) error {
// Open returns an error if the config file is not present.
func
(
c
*
ConfigComponent
)
Open
()
error
{
configFilename
,
err
:=
config
.
Filename
(
c
.
P
ath
)
configFilename
,
err
:=
config
.
Filename
(
c
.
p
ath
)
if
err
!=
nil
{
return
err
}
...
...
@@ -67,7 +67,7 @@ func (c *ConfigComponent) SetConfig(updated *config.Config) error {
// GetConfigKey retrieves only the value of a particular key.
func
(
c
*
ConfigComponent
)
GetConfigKey
(
key
string
)
(
interface
{},
error
)
{
filename
,
err
:=
config
.
Filename
(
c
.
P
ath
)
filename
,
err
:=
config
.
Filename
(
c
.
p
ath
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -80,7 +80,7 @@ func (c *ConfigComponent) GetConfigKey(key string) (interface{}, error) {
// SetConfigKey writes the value of a particular key.
func
(
c
*
ConfigComponent
)
SetConfigKey
(
key
string
,
value
interface
{})
error
{
filename
,
err
:=
config
.
Filename
(
c
.
P
ath
)
filename
,
err
:=
config
.
Filename
(
c
.
p
ath
)
if
err
!=
nil
{
return
err
}
...
...
@@ -103,6 +103,10 @@ func (c *ConfigComponent) SetConfigKey(key string, value interface{}) error {
return
c
.
setConfigUnsynced
(
conf
)
// TODO roll this into this method
}
func
(
c
*
ConfigComponent
)
SetPath
(
p
string
)
{
c
.
path
=
p
}
// ConfigComponentIsInitialized returns true if the repo is initialized at
// provided |path|.
func
ConfigComponentIsInitialized
(
path
string
)
bool
{
...
...
@@ -118,7 +122,7 @@ func ConfigComponentIsInitialized(path string) bool {
// setConfigUnsynced is for private use.
func
(
r
*
ConfigComponent
)
setConfigUnsynced
(
updated
*
config
.
Config
)
error
{
configFilename
,
err
:=
config
.
Filename
(
r
.
P
ath
)
configFilename
,
err
:=
config
.
Filename
(
r
.
p
ath
)
if
err
!=
nil
{
return
err
}
...
...
repo/fsrepo/fsrepo.go
浏览文件 @
7ad559b8
...
...
@@ -314,7 +314,8 @@ func componentBuilders() []componentBuilder {
Init
:
component
.
InitConfigComponent
,
IsInitialized
:
component
.
ConfigComponentIsInitialized
,
OpenHandler
:
func
(
r
*
FSRepo
)
error
{
cc
:=
component
.
ConfigComponent
{
Path
:
r
.
path
}
cc
:=
component
.
ConfigComponent
{}
cc
.
SetPath
(
r
.
path
)
if
err
:=
cc
.
Open
();
err
!=
nil
{
return
err
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论