diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-10 23:08:55 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-10 23:08:55 +0100 |
| commit | b0dceea396d8c7b7702e57b51d46b4a12a003902 (patch) | |
| tree | b344d3d3ab393554c0fe02c3510b260245e88792 /src/zencore/filesystem.cpp | |
| parent | fix bad access to unlocked state (#527) (diff) | |
| download | zen-b0dceea396d8c7b7702e57b51d46b4a12a003902.tar.xz zen-b0dceea396d8c7b7702e57b51d46b4a12a003902.zip | |
If a directory is deleted while we try to traverse it, skip it and continue (#528)
Diffstat (limited to 'src/zencore/filesystem.cpp')
| -rw-r--r-- | src/zencore/filesystem.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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())); } |