aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-10 21:45:18 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-12 12:11:47 +0300
commit29c9e2c2d2015ade47ed4497926363dea3f9c59b (patch)
treece764460e1b629baadd5d8a9eec5766e585d648d
parent32692d26813ba099c1451ae5941d38923bec761c (diff)
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.
-rw-r--r--src/wallet/db.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index cd49baeb78..5bf037b222 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -18,7 +18,12 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
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;
}