Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Add warning on startup about old testnet data.
Browse files Browse the repository at this point in the history
Done in a loop so future testnets can be added in as needed.
  • Loading branch information
jcvernaleo committed Mar 22, 2017
1 parent 9b76b78 commit 68deca1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ func loadConfig() (*config, []string, error) {
// All data is specific to a network, so namespacing the data directory
// means each individual piece of serialized data does not have to
// worry about changing names per network and such.
//
// Make list of old versions of testnet directories here since the
// network specific DataDir will be used after this.
cfg.DataDir = cleanAndExpandPath(cfg.DataDir)
var oldTestNets []string
oldTestNets = append(oldTestNets, filepath.Join(cfg.DataDir, "testnet"))
cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))

// Append the network type to the log directory so it is "namespaced"
Expand Down Expand Up @@ -941,6 +946,15 @@ func loadConfig() (*config, []string, error) {
}
}

// Warn if old testnet directory is present.
for _, oldDir := range oldTestNets {
if fileExists(oldDir) {
dcrdLog.Warnf("Block chain data from previous testnet"+
" found (%v) and can probably be removed.",
oldDir)
}
}

// Warn about missing config file only after all other configuration is
// done. This prevents the warning on help messages and invalid
// options. Note this should go directly before the return.
Expand Down

0 comments on commit 68deca1

Please sign in to comment.