diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -4,6 +4,7 @@ #include +#include #include fs::path GetWalletDir() { @@ -32,7 +33,11 @@ // A Berkeley DB Btree file has at least 4K. // This check also prevents opening lock files. boost::system::error_code ec; - if (fs::file_size(path, ec) < 4096) { + auto size = fs::file_size(path, ec); + if (ec) { + LogPrintf("%s: %s %s\n", __func__, ec.message(), path.string()); + } + if (size < 4096) { return false; } @@ -58,9 +63,16 @@ const fs::path wallet_dir = GetWalletDir(); const size_t offset = wallet_dir.string().size() + 1; std::vector paths; + boost::system::error_code ec; + + for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); + it != fs::recursive_directory_iterator(); it.increment(ec)) { + if (ec) { + LogPrintf("%s: %s %s\n", __func__, ec.message(), + it->path().string()); + continue; + } - for (auto it = fs::recursive_directory_iterator(wallet_dir); - it != fs::recursive_directory_iterator(); ++it) { // 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.