Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c5da1561
提交
c5da1561
authored
1月 12, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check datastore directory when opening the repo for use
上级
0d88f70c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
11 行删除
+40
-11
init.go
cmd/ipfs/init.go
+7
-10
fsrepo.go
repo/fsrepo/fsrepo.go
+33
-1
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
c5da1561
...
...
@@ -145,18 +145,15 @@ func addTheWelcomeFile(conf *config.Config) error {
return
nil
}
func
datastoreConfig
()
(
config
.
Datastore
,
error
)
{
ds
:=
config
.
Datastore
{}
func
datastoreConfig
()
(
*
config
.
Datastore
,
error
)
{
dspath
,
err
:=
config
.
DataStorePath
(
""
)
if
err
!=
nil
{
return
ds
,
err
}
ds
.
Path
=
dspath
ds
.
Type
=
"leveldb"
if
err
:=
initCheckDir
(
dspath
);
err
!=
nil
{
return
ds
,
debugerror
.
Errorf
(
"datastore: %s"
,
err
)
return
nil
,
err
}
return
ds
,
nil
return
&
config
.
Datastore
{
Path
:
dspath
,
Type
:
"leveldb"
,
},
nil
}
func
initConfig
(
nBitsForKeypair
int
)
(
*
config
.
Config
,
error
)
{
...
...
@@ -193,7 +190,7 @@ func initConfig(nBitsForKeypair int) (*config.Config, error) {
},
Bootstrap
:
bootstrapPeers
,
Datastore
:
ds
,
Datastore
:
*
ds
,
Logs
:
logConfig
,
Identity
:
identity
,
...
...
repo/fsrepo/fsrepo.go
浏览文件 @
c5da1561
...
...
@@ -2,9 +2,12 @@ package fsrepo
import
(
"io"
"os"
"path/filepath"
config
"github.com/jbenet/go-ipfs/repo/config"
util
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/debugerror"
)
type
FSRepo
struct
{
...
...
@@ -19,8 +22,22 @@ func At(path string) *FSRepo {
}
func
(
r
*
FSRepo
)
Open
()
error
{
//
TODO may need to check that directory is writeable
//
check repo path, then check all constituent parts.
// TODO acquire repo lock
// TODO if err := initCheckDir(logpath); err != nil { // }
if
err
:=
initCheckDir
(
r
.
path
);
err
!=
nil
{
return
err
}
// datastore
dspath
,
err
:=
config
.
DataStorePath
(
""
)
if
err
!=
nil
{
return
err
}
if
err
:=
initCheckDir
(
dspath
);
err
!=
nil
{
return
debugerror
.
Errorf
(
"datastore: %s"
,
err
)
}
return
nil
}
...
...
@@ -53,3 +70,18 @@ func ConfigIsInitialized(path string) bool {
}
return
true
}
// initCheckDir ensures the directory exists and is writable
func
initCheckDir
(
path
string
)
error
{
// Construct the path if missing
if
err
:=
os
.
MkdirAll
(
path
,
os
.
ModePerm
);
err
!=
nil
{
return
err
}
// Check the directory is writeable
if
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
path
,
"._check_writeable"
));
err
==
nil
{
os
.
Remove
(
f
.
Name
())
}
else
{
return
debugerror
.
New
(
"'"
+
path
+
"' is not writeable"
)
}
return
nil
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论