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.
This commit is contained in:
Hennadii Stepanov 2022-02-04 22:53:04 +02:00
parent b2a8371913
commit b9c113af75
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -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;
}