Skip to content

Commit 15c69b1

Browse files
committed
wallet: Log and ignore errors in ListWalletDir and IsBerkeleyBtree
1 parent 257f750 commit 15c69b1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/wallet/walletutil.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <wallet/walletutil.h>
66

7+
#include <logging.h>
78
#include <util/system.h>
89

910
fs::path GetWalletDir()
@@ -33,7 +34,9 @@ static bool IsBerkeleyBtree(const fs::path& path)
3334
// A Berkeley DB Btree file has at least 4K.
3435
// This check also prevents opening lock files.
3536
boost::system::error_code ec;
36-
if (fs::file_size(path, ec) < 4096) return false;
37+
auto size = fs::file_size(path, ec);
38+
if (ec) LogPrintf("%s: %s %s\n", __func__, ec.message(), path.string());
39+
if (size < 4096) return false;
3740

3841
fsbridge::ifstream file(path, std::ios::binary);
3942
if (!file.is_open()) return false;
@@ -54,8 +57,14 @@ std::vector<fs::path> ListWalletDir()
5457
const fs::path wallet_dir = GetWalletDir();
5558
const size_t offset = wallet_dir.string().size() + 1;
5659
std::vector<fs::path> paths;
60+
boost::system::error_code ec;
61+
62+
for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
63+
if (ec) {
64+
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
65+
continue;
66+
}
5767

58-
for (auto it = fs::recursive_directory_iterator(wallet_dir); it != fs::recursive_directory_iterator(); ++it) {
5968
// Get wallet path relative to walletdir by removing walletdir from the wallet path.
6069
// This can be replaced by boost::filesystem::lexically_relative once boost is bumped to 1.60.
6170
const fs::path path = it->path().string().substr(offset);

0 commit comments

Comments
 (0)