diff options
| author | Pierre Rochard <[email protected]> | 2018-09-10 20:50:42 -0400 |
|---|---|---|
| committer | Pierre Rochard <[email protected]> | 2018-09-12 21:05:53 -0400 |
| commit | 2d471636eb9160ab51b08e491e3f003f57adbc36 (patch) | |
| tree | 234651e8d6c32485f982fd3a38f2723d49efe5ea /src/wallet/init.cpp | |
| parent | wallet: Add walletdir arg unit tests (diff) | |
| download | discoin-2d471636eb9160ab51b08e491e3f003f57adbc36.tar.xz discoin-2d471636eb9160ab51b08e491e3f003f57adbc36.zip | |
wallet: Remove trailing separators from -walletdir arg
Diffstat (limited to 'src/wallet/init.cpp')
| -rw-r--r-- | src/wallet/init.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index a299a4ee4..46983642f 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -182,13 +182,18 @@ bool WalletInit::Verify() const if (gArgs.IsArgSet("-walletdir")) { fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); - if (!fs::exists(wallet_dir)) { + boost::system::error_code error; + // The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory + fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error); + if (error || !fs::exists(wallet_dir)) { return InitError(strprintf(_("Specified -walletdir \"%s\" does not exist"), wallet_dir.string())); } else if (!fs::is_directory(wallet_dir)) { return InitError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), wallet_dir.string())); + // The canonical path transforms relative paths into absolute ones, so we check the non-canonical version } else if (!wallet_dir.is_absolute()) { return InitError(strprintf(_("Specified -walletdir \"%s\" is a relative path"), wallet_dir.string())); } + gArgs.ForceSetArg("-walletdir", canonical_wallet_dir.string()); } LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); |