From 1dc79571fff79a9ab9e5f0eeb55067b4857034a6 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Tue, 19 Nov 2024 13:27:42 -0800 Subject: [PATCH] [Windows] FileManager.enumerator(at:) default error handler should continue rather than exiting --- Sources/Foundation/FileManager+Win32.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Foundation/FileManager+Win32.swift b/Sources/Foundation/FileManager+Win32.swift index c4d2ceaff9..abc44c02f6 100644 --- a/Sources/Foundation/FileManager+Win32.swift +++ b/Sources/Foundation/FileManager+Win32.swift @@ -322,11 +322,11 @@ extension FileManager { override func nextObject() -> Any? { func firstValidItem() -> URL? { while let url = _stack.popLast() { - if !FileManager.default.fileExists(atPath: url.path) { - guard let handler = _errorHandler else { return nil } - if !handler(url, _NSErrorWithWindowsError(GetLastError(), reading: true, paths: [url.path])) { + guard FileManager.default.fileExists(atPath: url.path) else { + if let handler = _errorHandler, !handler(url, _NSErrorWithWindowsError(GetLastError(), reading: true, paths: [url.path])) { return nil } + continue } _lastReturned = url return _lastReturned