diff options
| author | Luke Dashjr <[email protected]> | 2020-07-13 03:01:57 +0000 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2020-11-06 04:17:54 +0000 |
| commit | 69f59af54d15ee9800d5df86bcdb0e962c71e7c3 (patch) | |
| tree | ccd75690a44c64790c4d1102ce85472701835f1d /src/wallet | |
| parent | Merge #20316: test: Fix wallet_multiwallet test issue on Windows (diff) | |
| download | discoin-69f59af54d15ee9800d5df86bcdb0e962c71e7c3.tar.xz discoin-69f59af54d15ee9800d5df86bcdb0e962c71e7c3.zip | |
Bugfix: Wallet: Soft-fail exceptions within ListWalletDir file checks
Diffstat (limited to 'src/wallet')
| -rw-r--r-- | src/wallet/walletutil.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 2f3e597b9..6563c4513 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -49,26 +49,31 @@ std::vector<fs::path> ListWalletDir() continue; } - // Get wallet path relative to walletdir by removing walletdir from the wallet path. - // This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60. - const fs::path path = it->path().string().substr(offset); + try { + // Get wallet path relative to walletdir by removing walletdir from the wallet path. + // This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60. + const fs::path path = it->path().string().substr(offset); - if (it->status().type() == fs::directory_file && - (ExistsBerkeleyDatabase(it->path()) || ExistsSQLiteDatabase(it->path()))) { - // Found a directory which contains wallet.dat btree file, add it as a wallet. - paths.emplace_back(path); - } else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsBerkeleyDatabase(it->path())) { - if (it->path().filename() == "wallet.dat") { - // Found top-level wallet.dat btree file, add top level directory "" - // as a wallet. - paths.emplace_back(); - } else { - // Found top-level btree file not called wallet.dat. Current bitcoin - // software will never create these files but will allow them to be - // opened in a shared database environment for backwards compatibility. - // Add it to the list of available wallets. + if (it->status().type() == fs::directory_file && + (ExistsBerkeleyDatabase(it->path()) || ExistsSQLiteDatabase(it->path()))) { + // Found a directory which contains wallet.dat btree file, add it as a wallet. paths.emplace_back(path); + } else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && ExistsBerkeleyDatabase(it->path())) { + if (it->path().filename() == "wallet.dat") { + // Found top-level wallet.dat btree file, add top level directory "" + // as a wallet. + paths.emplace_back(); + } else { + // Found top-level btree file not called wallet.dat. Current bitcoin + // software will never create these files but will allow them to be + // opened in a shared database environment for backwards compatibility. + // Add it to the list of available wallets. + paths.emplace_back(path); + } } + } catch (const std::exception& e) { + LogPrintf("%s: Error scanning %s: %s\n", __func__, it->path().string(), e.what()); + it.no_push(); } } |