mirror of
https://github.com/QuasarApp/QuasarAppCoin.git
synced 2025-05-10 16:39:37 +00:00
wallet: Log and ignore errors in ListWalletDir and IsBerkeleyBtree
Github-Pull: #15583 Rebased-From: 15c69b158da570f4e1430280c610e94ffdee0e51 Tree-SHA512: edef7cafc5a2cb8d3355591a7742ef61454a5dedbb1dc22f6cc6bae42329d887f3f4a054f2aeedf31180051f50b6478d09e204066205699dabc0cb67b0ce4a96
This commit is contained in:
parent
a01925c150
commit
ef27a060ac
@ -4,6 +4,7 @@
|
||||
|
||||
#include <wallet/walletutil.h>
|
||||
|
||||
#include <logging.h>
|
||||
#include <util/system.h>
|
||||
|
||||
fs::path GetWalletDir()
|
||||
@ -33,7 +34,9 @@ static bool IsBerkeleyBtree(const fs::path& path)
|
||||
// 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) return false;
|
||||
auto size = fs::file_size(path, ec);
|
||||
if (ec) LogPrintf("%s: %s %s\n", __func__, ec.message(), path.string());
|
||||
if (size < 4096) return false;
|
||||
|
||||
fsbridge::ifstream file(path, std::ios::binary);
|
||||
if (!file.is_open()) return false;
|
||||
@ -54,8 +57,14 @@ std::vector<fs::path> ListWalletDir()
|
||||
const fs::path wallet_dir = GetWalletDir();
|
||||
const size_t offset = wallet_dir.string().size() + 1;
|
||||
std::vector<fs::path> 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.
|
||||
const fs::path path = it->path().string().substr(offset);
|
||||
|
Loading…
x
Reference in New Issue
Block a user