Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
b6603051
提交
b6603051
authored
1月 14, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extract initCheckDir to dir.Writable
上级
887fbe4a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
18 行删除
+27
-18
dir.go
repo/fsrepo/dir/dir.go
+24
-0
fsrepo.go
repo/fsrepo/fsrepo.go
+3
-18
没有找到文件。
repo/fsrepo/dir/dir.go
0 → 100644
浏览文件 @
b6603051
package
dir
// TODO move somewhere generic
import
(
"errors"
"os"
"path/filepath"
)
// Writable ensures the directory exists and is writable
func
Writable
(
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
errors
.
New
(
"'"
+
path
+
"' is not writeable"
)
}
return
nil
}
repo/fsrepo/fsrepo.go
浏览文件 @
b6603051
...
...
@@ -6,12 +6,12 @@ import (
"io"
"os"
"path"
"path/filepath"
"sync"
repo
"github.com/jbenet/go-ipfs/repo"
config
"github.com/jbenet/go-ipfs/repo/config"
component
"github.com/jbenet/go-ipfs/repo/fsrepo/component"
dir
"github.com/jbenet/go-ipfs/repo/fsrepo/dir"
lockfile
"github.com/jbenet/go-ipfs/repo/fsrepo/lock"
opener
"github.com/jbenet/go-ipfs/repo/fsrepo/opener"
serialize
"github.com/jbenet/go-ipfs/repo/fsrepo/serialize"
...
...
@@ -148,7 +148,7 @@ func (r *FSRepo) Open() error {
// 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
{
if
err
:=
dir
.
Writable
(
r
.
path
);
err
!=
nil
{
return
err
}
...
...
@@ -162,7 +162,7 @@ func (r *FSRepo) Open() error {
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
if
err
:=
initCheckDir
(
logpath
);
err
!=
nil
{
if
err
:=
dir
.
Writable
(
logpath
);
err
!=
nil
{
return
debugerror
.
Errorf
(
"logs: %s"
,
err
)
}
...
...
@@ -264,21 +264,6 @@ func isInitializedUnsynced(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
}
// transitionToOpened manages the state transition to |opened|. Caller must hold
// the package mutex.
func
(
r
*
FSRepo
)
transitionToOpened
()
error
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论