From b0dceea396d8c7b7702e57b51d46b4a12a003902 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 10 Nov 2023 23:08:55 +0100 Subject: If a directory is deleted while we try to traverse it, skip it and continue (#528) --- src/zencore/filesystem.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/zencore/filesystem.cpp') 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())); } -- cgit v1.2.3