Skip to content

Commit 8edb041

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24266: util: Avoid buggy std::filesystem:::create_directories() call
b9c113a util: Avoid buggy std::filesystem:::create_directories() call (Hennadii Stepanov) Pull request description: Compiled with some libstdc++ versions (e.g., on Ubuntu 20.04) [`std::filesystem:::create_directories()`](https://en.cppreference.com/w/cpp/filesystem/create_directory) call [fails](bitcoin/bitcoin#24257 (comment)) to handle symbol links properly. No behavior change in comparison to the [pre-20744](bitcoin/bitcoin@c194293) master branch. Fixes bitcoin/bitcoin#24257. ACKs for top commit: ryanofsky: Code review ACK b9c113a. Nice simplification and fix MarcoFalke: review ACK b9c113a 🐬 Tree-SHA512: 79d940cfc1f68d9b0548fb2ab005e90850b54ac0fb3bb2940afd632d56288d92687579a3176bac3fd0ea3d2dae71e26444f8f7bdb87862414c12866ae5e857c4
2 parents 8afcc89 + b9c113a commit 8edb041

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)