diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-04 22:53:04 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-05 18:32:39 +0200 |
commit | b9c113af754540341d9529532fbadb7525168102 (patch) | |
tree | cfcde655dd4e14f0030555af594962375e8cf60b /src/util/system.cpp | |
parent | b2a8371913a85701759b5a2d59d46e15f28ba68f (diff) |
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.
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r-- | src/util/system.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index 0ee63f6381..d51ba07d94 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; } |