wallet: Do not iterate a directory if having an error while accessing it

This change prevents infinite looping for, for example, system folders
on Windows.

Github-Pull: #21907
Rebased-From: 29c9e2c2d2
This commit is contained in:
Hennadii Stepanov 2021-05-10 21:45:18 +03:00 committed by Luke Dashjr
parent 8afa602f30
commit 7b0b201d10

View file

@ -63,7 +63,12 @@ std::vector<fs::path> ListWalletDir()
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());
if (fs::is_directory(*it)) {
it.no_push();
LogPrintf("%s: %s %s -- skipping.\n", __func__, ec.message(), it->path().string());
} else {
LogPrintf("%s: %s %s\n", __func__, ec.message(), it->path().string());
}
continue;
}