From e81738a41b64b3e493ac6853b9f0a63c48a8879e Mon Sep 17 00:00:00 2001 From: /raw PONG _GHMoaCXLT <58883403+q9f@users.noreply.github.com> Date: Thu, 2 Apr 2020 10:58:34 +0200 Subject: [PATCH] cmd/utils: create new ropsten configurations in the ropsten datadir --- cmd/utils/flags.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ec4dada011..f24dc6137a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -781,13 +781,6 @@ var ( func MakeDataDir(ctx *cli.Context) string { if path := ctx.GlobalString(DataDirFlag.Name); path != "" { 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 DatadirExists(legacyPath) { - log.Warn("Using the deprecated `testnet` datadir. Future versions will store the Ropsten chain in `ropsten`.") - return legacyPath - } return filepath.Join(path, "ropsten") } if ctx.GlobalBool(RinkebyFlag.Name) { @@ -1254,7 +1247,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) { // Maintain compatibility with older Geth configurations storing the // Ropsten database in `testnet` instead of `ropsten`. legacyPath := filepath.Join(node.DefaultDataDir(), "testnet") - if DatadirExists(legacyPath) { + if _, err := os.Stat(legacyPath); !os.IsNotExist(err) { + log.Warn("Using the deprecated `testnet` datadir. Future versions will store the Ropsten chain in `ropsten`.") cfg.DataDir = legacyPath } else { cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ropsten") @@ -1831,15 +1825,3 @@ func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error return action(ctx) } } - -// DatadirExists checks wether the datadir in `path` exists or not. -// -// E.g., can be used to determine wether to use the old `testnet` directory for -// Ropsten or create a new `ropsten` datadir instead. -func DatadirExists(path string) bool { - if _, err := os.Stat(path); !os.IsNotExist(err) { - return true - } else { - return false - } -}