aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-02-08 15:46:30 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-02-08 15:46:34 +0100
commit8edb0416dd4a13f6fae0c7f2f2061dd6f9365a0e (patch)
treee991bc8b8a88315cce31aa165b7364bef52c236c
parent8afcc89a8f96692dd880b6102c9a85fac18b9021 (diff)
parentb9c113af754540341d9529532fbadb7525168102 (diff)
Merge bitcoin/bitcoin#24266: util: Avoid buggy std::filesystem:::create_directories() call
b9c113af754540341d9529532fbadb7525168102 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](https://github.com/bitcoin/bitcoin/issues/24257#issue-1123753243) to handle symbol links properly. No behavior change in comparison to the [pre-20744](https://github.com/bitcoin/bitcoin/commit/c194293883fbb656779102309b2cb3e60889feff) master branch. Fixes bitcoin/bitcoin#24257. ACKs for top commit: ryanofsky: Code review ACK b9c113af754540341d9529532fbadb7525168102. Nice simplification and fix MarcoFalke: review ACK b9c113af754540341d9529532fbadb7525168102 🐬 Tree-SHA512: 79d940cfc1f68d9b0548fb2ab005e90850b54ac0fb3bb2940afd632d56288d92687579a3176bac3fd0ea3d2dae71e26444f8f7bdb87862414c12866ae5e857c4
-rw-r--r--src/util/system.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 8d0cec249d..4ead39dd6c 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -443,14 +443,18 @@ const fs::path& ArgsManager::GetDataDir(bool net_specific) const
} else {
path = GetDefaultDataDir();
}
- if (net_specific)
- path /= fs::PathFromString(BaseParams().DataDir());
- if (fs::create_directories(path)) {
- // This is the first run, create wallets subdirectory too
+ if (!fs::exists(path)) {
fs::create_directories(path / "wallets");
}
+ if (net_specific && !BaseParams().DataDir().empty()) {
+ path /= fs::PathFromString(BaseParams().DataDir());
+ if (!fs::exists(path)) {
+ fs::create_directories(path / "wallets");
+ }
+ }
+
path = StripRedundantLastElementsOfPath(path);
return path;
}