cmd/utils: makedatadir should check for existing testnet dir

This commit is contained in:
/raw PONG _GHMoaCXLT 2020-04-06 12:06:36 +02:00
parent e81738a41b
commit 5e0f03aacf
No known key found for this signature in database
GPG key ID: E79CDFA171DC2DF9

View file

@ -781,6 +781,12 @@ var (
func MakeDataDir(ctx *cli.Context) string { func MakeDataDir(ctx *cli.Context) string {
if path := ctx.GlobalString(DataDirFlag.Name); path != "" { if path := ctx.GlobalString(DataDirFlag.Name); path != "" {
if ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name) { if ctx.GlobalBool(LegacyTestnetFlag.Name) || ctx.GlobalBool(RopstenFlag.Name) {
// Maintain compatibility with older Geth configurations storing the
// Ropsten database in `testnet` instead of `ropsten`.
legacyPath := filepath.Join(path, "testnet")
if _, err := os.Stat(legacyPath); !os.IsNotExist(err) {
return legacyPath
}
return filepath.Join(path, "ropsten") return filepath.Join(path, "ropsten")
} }
if ctx.GlobalBool(RinkebyFlag.Name) { if ctx.GlobalBool(RinkebyFlag.Name) {