mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Don't try to create empty datadir before the real path is known (#1494)
Fixes: #1345 The actual problem is that GetDataDir has the side effect of creating the datadir, even if it is not known yet where it really is. This is only known after reading the config file or when explicitly specified in the cmd line. Thus, if GetDataDir gets called before the datadir value from the config is read, it tries to create it at the default location.
This commit is contained in:
parent
5d27950296
commit
1d67d52122
@ -92,7 +92,8 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false))) {
|
||||
bool datadirFromCmdLine = mapArgs.count("-datadir") != 0;
|
||||
if (datadirFromCmdLine && !boost::filesystem::is_directory(GetDataDir(false))) {
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@ -102,6 +103,10 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!datadirFromCmdLine && !boost::filesystem::is_directory(GetDataDir(false))) {
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
|
||||
try {
|
||||
SelectBaseParams(ChainNameFromCommandLine());
|
||||
|
@ -96,7 +96,8 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
try
|
||||
{
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||
bool datadirFromCmdLine = mapArgs.count("-datadir") != 0;
|
||||
if (datadirFromCmdLine && !boost::filesystem::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
return false;
|
||||
@ -108,6 +109,11 @@ bool AppInit(int argc, char* argv[])
|
||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
if (!datadirFromCmdLine && !boost::filesystem::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(ChainNameFromCommandLine());
|
||||
|
Loading…
Reference in New Issue
Block a user