Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
cc73137f
提交
cc73137f
authored
7月 06, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add migrate flag to daemon subcommand
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
2db7522f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
24 行删除
+38
-24
daemon.go
cmd/ipfs/daemon.go
+33
-9
fsrepo.go
repo/fsrepo/fsrepo.go
+4
-14
mock.go
repo/mock.go
+1
-1
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
cc73137f
...
...
@@ -23,6 +23,7 @@ import (
"github.com/ipfs/go-ipfs/core/corerouting"
nodeMount
"github.com/ipfs/go-ipfs/fuse/node"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
migrate
"github.com/ipfs/go-ipfs/repo/fsrepo/migrations"
pstore
"gx/ipfs/QmQdnfvZQuhdT93LNc5bos52wAmdr3G2p6G8teLJMEN32P/go-libp2p-peerstore"
conn
"gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/net/conn"
util
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
...
...
@@ -30,18 +31,19 @@ import (
)
const
(
adjustFDLimitKwd
=
"manage-fdlimit"
enableGCKwd
=
"enable-gc"
initOptionKwd
=
"init"
routingOptionKwd
=
"routing"
routingOptionSupernodeKwd
=
"supernode"
mountKwd
=
"mount"
writableKwd
=
"writable"
ipfsMountKwd
=
"mount-ipfs"
ipnsMountKwd
=
"mount-ipns"
unrestrictedApiAccessKwd
=
"unrestricted-api"
unencryptTransportKwd
=
"disable-transport-encryption"
enableGCKwd
=
"enable-gc"
adjustFDLimitKwd
=
"manage-fdlimit"
migrateKwd
=
"migrate"
mountKwd
=
"mount"
offlineKwd
=
"offline"
routingOptionKwd
=
"routing"
routingOptionSupernodeKwd
=
"supernode"
unencryptTransportKwd
=
"disable-transport-encryption"
unrestrictedApiAccessKwd
=
"unrestricted-api"
writableKwd
=
"writable"
// apiAddrKwd = "address-api"
// swarmAddrKwd = "address-swarm"
)
...
...
@@ -139,6 +141,7 @@ Headers.
cmds
.
BoolOption
(
enableGCKwd
,
"Enable automatic periodic repo garbage collection"
)
.
Default
(
false
),
cmds
.
BoolOption
(
adjustFDLimitKwd
,
"Check and raise file descriptor limits if needed"
)
.
Default
(
true
),
cmds
.
BoolOption
(
offlineKwd
,
"Run offline. Do not connect to the rest of the network but provide local API."
)
.
Default
(
false
),
cmds
.
BoolOption
(
migrateKwd
,
"If true, assume yes at the migrate prompt. If false, assume no."
),
// TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
...
...
@@ -216,9 +219,30 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
// acquire the repo lock _before_ constructing a node. we need to make
// sure we are permitted to access the resources (datastore, etc.)
repo
,
err
:=
fsrepo
.
Open
(
req
.
InvocContext
()
.
ConfigRoot
)
if
err
!=
nil
{
switch
err
{
default
:
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
case
fsrepo
.
ErrNeedMigration
:
domigrate
,
found
,
_
:=
req
.
Option
(
migrateKwd
)
.
Bool
()
if
!
found
{
err
=
migrate
.
TryMigrating
(
fsrepo
.
RepoVersion
)
}
else
if
domigrate
{
err
=
migrate
.
RunMigration
(
fsrepo
.
RepoVersion
)
}
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
repo
,
err
=
fsrepo
.
Open
(
req
.
InvocContext
()
.
ConfigRoot
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
case
nil
:
break
}
cfg
,
err
:=
ctx
.
GetConfig
()
...
...
repo/fsrepo/fsrepo.go
浏览文件 @
cc73137f
...
...
@@ -43,8 +43,9 @@ a migration in reverse.
See https://github.com/ipfs/fs-repo-migrations/blob/master/run.md for details.`
var
(
ErrNoVersion
=
errors
.
New
(
"no version file found, please run 0-to-1 migration tool.
\n
"
+
migrationInstructions
)
ErrOldRepo
=
errors
.
New
(
"ipfs repo found in old '~/.go-ipfs' location, please run migration tool.
\n
"
+
migrationInstructions
)
ErrNoVersion
=
errors
.
New
(
"no version file found, please run 0-to-1 migration tool.
\n
"
+
migrationInstructions
)
ErrOldRepo
=
errors
.
New
(
"ipfs repo found in old '~/.go-ipfs' location, please run migration tool.
\n
"
+
migrationInstructions
)
ErrNeedMigration
=
errors
.
New
(
"ipfs repo needs migration."
)
)
type
NoRepoError
struct
{
...
...
@@ -141,18 +142,7 @@ func open(repoPath string) (repo.Repo, error) {
}
if
RepoVersion
>
ver
{
r
.
lockfile
.
Close
()
err
:=
mfsr
.
TryMigrating
(
RepoVersion
)
if
err
!=
nil
{
return
nil
,
err
}
r
.
lockfile
,
err
=
lockfile
.
Lock
(
r
.
path
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"reacquiring lock: %s"
,
err
)
}
return
nil
,
ErrNeedMigration
}
else
if
ver
>
RepoVersion
{
// program version too low for existing repo
return
nil
,
fmt
.
Errorf
(
programTooLowMessage
,
RepoVersion
,
ver
)
...
...
repo/mock.go
浏览文件 @
cc73137f
...
...
@@ -6,7 +6,7 @@ import (
"github.com/ipfs/go-ipfs/repo/config"
)
var
errTODO
=
errors
.
New
(
"TODO"
)
var
errTODO
=
errors
.
New
(
"TODO
: mock repo
"
)
// Mock is not thread-safe
type
Mock
struct
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论