Skip to content

Commit 5082409

Browse files
committed
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.
1 parent 740d41c commit 5082409

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/bitcoind.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ static bool AppInit(int argc, char* argv[])
9292

9393
try
9494
{
95-
if (!fs::is_directory(GetDataDir(false)))
96-
{
95+
if (!CheckDataDirOption()) {
9796
return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
9897
}
9998
if (!gArgs.ReadConfigFiles(error, true)) {

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
941941

942942
// If datadir is changed in .conf file:
943943
ClearDatadirCache();
944-
if (!fs::is_directory(GetDataDir(false))) {
944+
if (!CheckDataDirOption()) {
945945
error = strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", "").c_str());
946946
return false;
947947
}

0 commit comments

Comments
 (0)