Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
cc73137f
Commit
cc73137f
authored
8 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add migrate flag to daemon subcommand
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
2db7522f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
24 deletions
+38
-24
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+33
-9
repo/fsrepo/fsrepo.go
repo/fsrepo/fsrepo.go
+4
-14
repo/mock.go
repo/mock.go
+1
-1
No files found.
cmd/ipfs/daemon.go
View file @
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
()
...
...
This diff is collapsed.
Click to expand it.
repo/fsrepo/fsrepo.go
View file @
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
)
...
...
This diff is collapsed.
Click to expand it.
repo/mock.go
View file @
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
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment