Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c2ed8ad4
提交
c2ed8ad4
authored
3月 17, 2016
作者:
Jeromy
提交者:
Jeromy
4月 28, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove init -f option, its bad
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
49ea0f83
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
28 行删除
+9
-28
init.go
cmd/ipfs/init.go
+4
-18
fsrepo.go
repo/fsrepo/fsrepo.go
+0
-6
fsrepo_test.go
repo/fsrepo/fsrepo_test.go
+5
-4
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
c2ed8ad4
...
...
@@ -35,7 +35,6 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
Options
:
[]
cmds
.
Option
{
cmds
.
IntOption
(
"bits"
,
"b"
,
fmt
.
Sprintf
(
"Number of bits to use in the generated RSA private key (defaults to %d)"
,
nBitsForKeypairDefault
)),
cmds
.
BoolOption
(
"force"
,
"f"
,
"Overwrite existing config (if it exists)."
),
cmds
.
BoolOption
(
"empty-repo"
,
"e"
,
"Don't add and pin help files to the local storage."
),
// TODO need to decide whether to expose the override as a file or a
...
...
@@ -64,12 +63,6 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
return
}
force
,
_
,
err
:=
req
.
Option
(
"f"
)
.
Bool
()
// if !found, it's okay force == false
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
empty
,
_
,
err
:=
req
.
Option
(
"e"
)
.
Bool
()
// if !empty, it's okay empty == false
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
...
...
@@ -86,7 +79,7 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
nBitsForKeypair
=
nBitsForKeypairDefault
}
if
err
:=
doInit
(
os
.
Stdout
,
req
.
InvocContext
()
.
ConfigRoot
,
force
,
empty
,
nBitsForKeypair
);
err
!=
nil
{
if
err
:=
doInit
(
os
.
Stdout
,
req
.
InvocContext
()
.
ConfigRoot
,
empty
,
nBitsForKeypair
);
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
...
...
@@ -95,14 +88,13 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
var
errRepoExists
=
errors
.
New
(
`ipfs configuration file already exists!
Reinitializing would overwrite your keys.
(use -f to force overwrite)
`
)
func
initWithDefaults
(
out
io
.
Writer
,
repoRoot
string
)
error
{
return
doInit
(
out
,
repoRoot
,
false
,
false
,
nBitsForKeypairDefault
)
return
doInit
(
out
,
repoRoot
,
false
,
nBitsForKeypairDefault
)
}
func
doInit
(
out
io
.
Writer
,
repoRoot
string
,
force
bool
,
empty
bool
,
nBitsForKeypair
int
)
error
{
func
doInit
(
out
io
.
Writer
,
repoRoot
string
,
empty
bool
,
nBitsForKeypair
int
)
error
{
if
_
,
err
:=
fmt
.
Fprintf
(
out
,
"initializing ipfs node at %s
\n
"
,
repoRoot
);
err
!=
nil
{
return
err
}
...
...
@@ -111,7 +103,7 @@ func doInit(out io.Writer, repoRoot string, force bool, empty bool, nBitsForKeyp
return
err
}
if
fsrepo
.
IsInitialized
(
repoRoot
)
&&
!
force
{
if
fsrepo
.
IsInitialized
(
repoRoot
)
{
return
errRepoExists
}
...
...
@@ -120,12 +112,6 @@ func doInit(out io.Writer, repoRoot string, force bool, empty bool, nBitsForKeyp
return
err
}
if
fsrepo
.
IsInitialized
(
repoRoot
)
{
if
err
:=
fsrepo
.
Remove
(
repoRoot
);
err
!=
nil
{
return
err
}
}
if
err
:=
fsrepo
.
Init
(
repoRoot
,
conf
);
err
!=
nil
{
return
err
}
...
...
repo/fsrepo/fsrepo.go
浏览文件 @
c2ed8ad4
...
...
@@ -249,12 +249,6 @@ func Init(repoPath string, conf *config.Config) error {
return
nil
}
// Remove recursively removes the FSRepo at |path|.
func
Remove
(
repoPath
string
)
error
{
repoPath
=
filepath
.
Clean
(
repoPath
)
return
os
.
RemoveAll
(
repoPath
)
}
// LockedByOtherProcess returns true if the FSRepo is locked by another
// process. If true, then the repo cannot be opened by this process.
func
LockedByOtherProcess
(
repoPath
string
)
(
bool
,
error
)
{
...
...
repo/fsrepo/fsrepo_test.go
浏览文件 @
c2ed8ad4
...
...
@@ -3,6 +3,8 @@ package fsrepo
import
(
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
datastore
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
...
...
@@ -27,10 +29,9 @@ func TestInitIdempotence(t *testing.T) {
}
}
func
TestRemove
(
t
*
testing
.
T
)
{
t
.
Parallel
()
path
:=
testRepoPath
(
"foo"
,
t
)
assert
.
Nil
(
Remove
(
path
),
t
,
"can remove a repository"
)
func
Remove
(
repoPath
string
)
error
{
repoPath
=
filepath
.
Clean
(
repoPath
)
return
os
.
RemoveAll
(
repoPath
)
}
func
TestCanManageReposIndependently
(
t
*
testing
.
T
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论