From 50824093bb2d68fe1393dfd636fab5f8795faa5d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 24 Jul 2019 03:29:40 +0300 Subject: [PATCH] Fix datadir handling in bitcoind This prevents premature tries to access or create the default datadir. This is useful when the -datadir option is specified and the default datadir is unreachable. --- src/bitcoind.cpp | 3 +-- src/util/system.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 77367d6bb84..4037f6856d5 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -92,8 +92,7 @@ static bool AppInit(int argc, char* argv[]) try { - if (!fs::is_directory(GetDataDir(false))) - { + if (!CheckDataDirOption()) { return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))); } if (!gArgs.ReadConfigFiles(error, true)) { diff --git a/src/util/system.cpp b/src/util/system.cpp index 520ed35504e..4d8aa9ed908 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -941,7 +941,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) // If datadir is changed in .conf file: ClearDatadirCache(); - if (!fs::is_directory(GetDataDir(false))) { + if (!CheckDataDirOption()) { error = strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", "").c_str()); return false; }