diff --git a/src/util/system.cpp b/src/util/system.cpp index 0ee63f6381d..d51ba07d941 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; }