Skip to content

Commit b9c113a

Browse files
committed
util: Avoid buggy std::filesystem:::create_directories() call
Compiled with some libstdc++ versions (e.g., on Ubuntu 20.04) std::filesystem:::create_directories() call fails to handle symbol links properly.
1 parent b2a8371 commit b9c113a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/util/system.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,18 @@ const fs::path& ArgsManager::GetDataDir(bool net_specific) const
443443
} else {
444444
path = GetDefaultDataDir();
445445
}
446-
if (net_specific)
447-
path /= fs::PathFromString(BaseParams().DataDir());
448446

449-
if (fs::create_directories(path)) {
450-
// This is the first run, create wallets subdirectory too
447+
if (!fs::exists(path)) {
451448
fs::create_directories(path / "wallets");
452449
}
453450

451+
if (net_specific && !BaseParams().DataDir().empty()) {
452+
path /= fs::PathFromString(BaseParams().DataDir());
453+
if (!fs::exists(path)) {
454+
fs::create_directories(path / "wallets");
455+
}
456+
}
457+
454458
path = StripRedundantLastElementsOfPath(path);
455459
return path;
456460
}

0 commit comments

Comments
 (0)