Skip to content

Commit d1ace94

Browse files
authored
(128078378) FoundationEssentials: correct error handling for item removal (#610)
The condition of the error check was inverted as it was meant to be a `guard` statement. This was resulting in an infinite loop. With this we now pass a few additional tests and the test suite no longer hangs.
1 parent ff677ad commit d1ace94

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/FoundationEssentials/FileManager/FileOperations.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,12 @@ enum _FileOperations {
358358
try directory.withNTPathRepresentation {
359359
if RemoveDirectoryW($0) { return }
360360
let dwError: DWORD = GetLastError()
361-
if dwError == ERROR_DIR_NOT_EMPTY {
361+
guard dwError == ERROR_DIR_NOT_EMPTY else {
362362
let error = CocoaError.removeFileError(dwError, directory)
363363
guard (filemanager?._shouldProceedAfter(error: error, removingItemAtPath: directory) ?? false) else {
364364
throw error
365365
}
366+
return
366367
}
367368
stack.append(directory)
368369

0 commit comments

Comments
 (0)