New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return success from FileManager
recursive directory creation even if a directory was created by another thread concurrently.
#2700
Conversation
@swift-ci test linux |
throw _NSErrorWithErrno(errno, reading: false, path: path) | ||
} else if let attr = attributes { | ||
let posixError = errno | ||
if posixError == EEXIST && fileExists(atPath: path, isDirectory: &isDir) && isDir.boolValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test for EEXIST
is only needed on the last path component to check if is a file.
If an earlier mkdir()
fails because the existing path is a file there should be an ENOTDIR
error returned, which should also handle the edge case of path
being a directory when fileExists
is called but being replaced by a file before the next mkdir()
.
Would need an extra test with a pre-existing path with includes a file as the last component to check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EEXIST
is returned by mkdir
if the last path component already exists, regardless of whether it is a file or a directory. ENOTDIR
is returned if any of the path components aside from the last one is not a directory.
This is supported by the documentation and by the example in SR-12272, which shows mkdir
returning EEXIST
even though there are no files involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swift-ci please test linux
@millenomi Is the test job stuck or something? How come it has not run yet? |
Sometimes the traffic on CI is so high that requests get dropped. |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@swift-ci test linux |
@swift-ci test macOS |
…f a directory was created by another thread concurrently. If another thread creates one of the same directories in the target path, the `!fileExists` check may pass while the `mkdir` call fails with `EEXIST`. However, if the existing file is a directory, then that should still be a success. Fixes [SR-12272](https://bugs.swift.org/browse/SR-12272).
Resolved the conflict. Please re-trigger the tests. |
@swift-ci please test |
Yay, passed! Can we merge? |
@swift-ci please test and merge |
If another thread creates one of the same directories in the target path, the
!fileExists
check may pass while themkdir
call fails withEEXIST
. However, if the existing file is a directory, then that should still be a success.Fixes SR-12272.