diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-02-04 08:59:17 -0500 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-02-04 09:10:19 -0500 |
commit | d216bc8d76d7f4e9dce58b0bb732a2d4deaf23b6 (patch) | |
tree | 18f05294217e28a4d64b55476834600c99cfc897 /src/wallet/load.cpp | |
parent | 80cd64e84296f1166e133c237fa0afc046b01ce2 (diff) | |
download | bitcoin-d216bc8d76d7f4e9dce58b0bb732a2d4deaf23b6.tar.xz |
Re-enable walletinit_verify_walletdir_no_trailing2 test disabled in #20744
This should also fix an init error if a -walletdir with a trailing slash
is used on windows. This appears to be a real error and regression
introduced with #20744.
On windows (or at least wine), fs calls that actuallly access the
filesystem like fs::equivalent or fs::exists seem to treat directory
paths with trailing slashes as not existing, so it's necessary to
normalize these paths before using them. This change passes canonical
paths to fs calls validating the -walletdir path to fix this.
Diffstat (limited to 'src/wallet/load.cpp')
-rw-r--r-- | src/wallet/load.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 4949ed7dc9..6a74f2eb84 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -31,11 +31,13 @@ bool VerifyWallets(WalletContext& context) fs::path wallet_dir = fs::PathFromString(args.GetArg("-walletdir", "")); std::error_code error; // The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory + // It also lets the fs::exists and fs::is_directory checks below pass on windows, since they return false + // if a path has trailing slashes, and it strips trailing slashes. fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error); - if (error || !fs::exists(wallet_dir)) { + if (error || !fs::exists(canonical_wallet_dir)) { chain.initError(strprintf(_("Specified -walletdir \"%s\" does not exist"), fs::PathToString(wallet_dir))); return false; - } else if (!fs::is_directory(wallet_dir)) { + } else if (!fs::is_directory(canonical_wallet_dir)) { chain.initError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), fs::PathToString(wallet_dir))); return false; // The canonical path transforms relative paths into absolute ones, so we check the non-canonical version |