提交 c1b8d292 作者: Juan Batiz-Benet

repo: clean up migration errors

Improved the repo migration errors to provide instructions
to the user.
上级 bb7bf818
...@@ -31,9 +31,19 @@ import ( ...@@ -31,9 +31,19 @@ import (
// version number that we are currently expecting to see // version number that we are currently expecting to see
var RepoVersion = "2" var RepoVersion = "2"
var incorrectRepoFormat = "Repo has incorrect version: '%s'\nProgram version is: '%s'\nPlease run the appropriate migration tool before continuing" var migrationInstructions = `See https://github.com/ipfs/fs-repo-migrations/blob/master/run.md
Sorry for the inconvenience. In the future, these will run automatically.`
var ErrNoVersion = errors.New("version check failed, no version file found, please run 0-to-1 migration tool.") var errIncorrectRepoFmt = `Repo has incorrect version: %s
Program version is: %s
Please run the ipfs migration tool before continuing.
` + migrationInstructions
var (
ErrNoRepo = errors.New("no ipfs repo found. please run: ipfs init")
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)
)
const ( const (
leveldbDirectory = "datastore" leveldbDirectory = "datastore"
...@@ -124,7 +134,7 @@ func open(repoPath string) (repo.Repo, error) { ...@@ -124,7 +134,7 @@ func open(repoPath string) (repo.Repo, error) {
} }
if ver != RepoVersion { if ver != RepoVersion {
return nil, fmt.Errorf(incorrectRepoFormat, ver, RepoVersion) return nil, fmt.Errorf(errIncorrectRepoFmt, ver, RepoVersion)
} }
// check repo path, then check all constituent parts. // check repo path, then check all constituent parts.
...@@ -160,9 +170,9 @@ func checkInitialized(path string) error { ...@@ -160,9 +170,9 @@ func checkInitialized(path string) error {
if !isInitializedUnsynced(path) { if !isInitializedUnsynced(path) {
alt := strings.Replace(path, ".ipfs", ".go-ipfs", 1) alt := strings.Replace(path, ".ipfs", ".go-ipfs", 1)
if isInitializedUnsynced(alt) { if isInitializedUnsynced(alt) {
return debugerror.New("ipfs repo found in old '.go-ipfs' location, please run migration tool") return ErrOldRepo
} }
return debugerror.New("ipfs not initialized, please run 'ipfs init'") return ErrNoRepo
} }
return nil return nil
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论