diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/system.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index a411b73a16..7754ef3e01 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -34,6 +34,7 @@ #endif // __linux__ #include <algorithm> +#include <cassert> #include <fcntl.h> #include <sched.h> #include <sys/resource.h> @@ -665,6 +666,19 @@ fs::path GetDefaultDataDir() #endif } +namespace { +fs::path StripRedundantLastElementsOfPath(const fs::path& path) +{ + auto result = path; + while (result.filename().string() == ".") { + result = result.parent_path(); + } + + assert(fs::equivalent(result, path)); + return result; +} +} // namespace + static fs::path g_blocks_path_cache_net_specific; static fs::path pathCached; static fs::path pathCachedNetSpecific; @@ -692,6 +706,7 @@ const fs::path &GetBlocksDir() path /= BaseParams().DataDir(); path /= "blocks"; fs::create_directories(path); + path = StripRedundantLastElementsOfPath(path); return path; } @@ -722,6 +737,7 @@ const fs::path &GetDataDir(bool fNetSpecific) fs::create_directories(path / "wallets"); } + path = StripRedundantLastElementsOfPath(path); return path; } |