aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-10 23:08:55 +0100
committerGitHub <[email protected]>2023-11-10 23:08:55 +0100
commitb0dceea396d8c7b7702e57b51d46b4a12a003902 (patch)
treeb344d3d3ab393554c0fe02c3510b260245e88792
parentfix bad access to unlocked state (#527) (diff)
downloadzen-b0dceea396d8c7b7702e57b51d46b4a12a003902.tar.xz
zen-b0dceea396d8c7b7702e57b51d46b4a12a003902.zip
If a directory is deleted while we try to traverse it, skip it and continue (#528)
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zencore/filesystem.cpp11
2 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88bf629af..804828c38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
- Bugfix: Server log files were using the wrong log line prefix due to a mistake when consolidating logging setup code
- Bugfix: Sponsor processes are now registered synchronously at startup, to close potential race condition in very short-lived subprocesses such as the automated tests
- Bugfix: Fix error in GC when reclaiming disk reserve is not enough to accommodate the new block
+- Bugfix: If a directory is deleted while we try to traverse it, skip it and continue
- Improvement: Multithread init and flush of cache bucket for faster startup and exit
- Improvement: Renamed BlockStoreCompactState::AddBlock to BlockStoreCompactState::IncludeBlock for clarity
- Improvement: Added tests for BlockStore::CompactBlocks
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index e9f7ba72c..b64c9973e 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -982,6 +982,11 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr
if (FAILED(hRes))
{
+ if (hRes == ERROR_FILE_NOT_FOUND)
+ {
+ // Directory no longer exist, treat it as empty
+ return;
+ }
ThrowSystemException(hRes, fmt::format("Failed to open handle to '{}'", RootDir));
}
@@ -1057,6 +1062,12 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr
DIR* Dir = opendir(RootDir.c_str());
if (Dir == nullptr)
{
+ int Err = errno;
+ if (Err == ENOENT)
+ {
+ // Directory no longer exist, treat it as empty
+ return;
+ }
ThrowLastError(fmt::format("Failed to open directory for traversal: {}", RootDir.c_str()));
}