aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuel Dobson <dobsonsa68@gmail.com>2021-05-13 21:06:48 +1200
committerSamuel Dobson <dobsonsa68@gmail.com>2021-05-13 21:09:32 +1200
commita31a1ceec721c8b7fb78e657e572c7a621d4d37e (patch)
tree824c04ab66492494122789f0e7f8abf264ed6c96 /src
parent386ba92e836387302eb2005b816dd9f972cdb5bc (diff)
parent29c9e2c2d2015ade47ed4497926363dea3f9c59b (diff)
downloadbitcoin-a31a1ceec721c8b7fb78e657e572c7a621d4d37e.tar.xz
Merge bitcoin/bitcoin#21907: wallet: Do not iterate a directory if having an error while accessing it
29c9e2c2d2015ade47ed4497926363dea3f9c59b wallet: Do not iterate a directory if having an error while accessing it (Hennadii Stepanov) Pull request description: On Windows when `ListDatabases` tries to iterate any system folder, e.g., "System Volume Information", it falls into an infinite loop. This PR fixes this bug. Now the `debug.log` contains: ``` 2021-05-12T09:07:53Z ListDatabases: Access is denied D:/System Volume Information -- skipping. ``` An easy way to reproduce the bug and test this PR is to pass the `-walletdir=D:\` command-line option, and run the `listwalletdir` RPC, or File -> Open Wallet in the GUI menu. Fixes #20081. Fixes #21136. Fixes #21904. Also https://bitcoin.stackexchange.com/questions/99243/listwalletdir-access-is-denied-d-system-volume-information ACKs for top commit: prayank23: ACK https://github.com/bitcoin/bitcoin/pull/21907/commits/29c9e2c2d2015ade47ed4497926363dea3f9c59b promag: Code review ACK 29c9e2c2d2015ade47ed4497926363dea3f9c59b. meshcollider: Code review ACK 29c9e2c2d2015ade47ed4497926363dea3f9c59b Tree-SHA512: b851c88e6d09626f4cb81acc2fa59a563b2aee64582963285715bf785c64b872e8bf738aa6b27bdbaf4c3e5c8565c2dc2c802135f9aa1f48b4b913435bc5d793
Diffstat (limited to 'src')
-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;
}