revert dash#1494: Don't try to create empty datadir before the real path is known

This commit is contained in:
Kittywhiskers Van Gogh 2022-06-02 22:24:10 +05:30
parent c34638d20b
commit cb4d60159d
2 changed files with 2 additions and 13 deletions

View File

@ -138,8 +138,7 @@ static int AppInitRPC(int argc, char* argv[])
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
bool datadirFromCmdLine = gArgs.IsArgSet("-datadir"); if (!fs::is_directory(GetDataDir(false))) {
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")); tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -147,10 +146,6 @@ static int AppInitRPC(int argc, char* argv[])
tfm::format(std::cerr, "Error reading configuration file: %s\n", error); tfm::format(std::cerr, "Error reading configuration file: %s\n", error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
tfm::format(std::cerr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", ""));
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
try { try {
SelectBaseParams(gArgs.GetChainName()); SelectBaseParams(gArgs.GetChainName());

View File

@ -87,19 +87,13 @@ static bool AppInit(int argc, char* argv[])
util::Ref context{node}; util::Ref context{node};
try try
{ {
bool datadirFromCmdLine = gArgs.IsArgSet("-datadir"); if (!fs::is_directory(GetDataDir(false)))
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{ {
return InitError(Untranslated(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")))); return InitError(Untranslated(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))));
} }
if (!gArgs.ReadConfigFiles(error, true)) { if (!gArgs.ReadConfigFiles(error, true)) {
return InitError(Untranslated(strprintf("Error reading configuration file: %s\n", error))); return InitError(Untranslated(strprintf("Error reading configuration file: %s\n", error)));
} }
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{
tfm::format(std::cerr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", ""));
return EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try { try {
SelectParams(gArgs.GetChainName()); SelectParams(gArgs.GetChainName());