提交 44f3d95c 作者: Brian Tiger Chow

refactor(repo/fsrepo): use repo to check whether config exists

上级 5b3164de
......@@ -18,6 +18,7 @@ import (
peer "github.com/jbenet/go-ipfs/p2p/peer"
repo "github.com/jbenet/go-ipfs/repo"
config "github.com/jbenet/go-ipfs/repo/config"
"github.com/jbenet/go-ipfs/repo/fsrepo"
u "github.com/jbenet/go-ipfs/util"
debugerror "github.com/jbenet/go-ipfs/util/debugerror"
)
......@@ -99,7 +100,7 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
return nil, debugerror.New("Couldn't get home directory path")
}
if u.FileExists(configFilename) && !force {
if fsrepo.ConfigIsInitialized(configRoot) && !force {
return nil, errCannotInitConfigExists
}
......
package fsrepo
import (
config "github.com/jbenet/go-ipfs/repo/config"
util "github.com/jbenet/go-ipfs/util"
)
// ConfigIsInitialized returns true if the config exists in provided |path|.
func ConfigIsInitialized(path string) bool {
configFilename, err := config.Filename(path)
if err != nil {
return false
}
if !util.FileExists(configFilename) {
return false
}
return true
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论