You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packagefunc _copyItem(at source:URL, to destination:URL)throws{
149
+
// Call `NSFileManager/copyItem(at:to:)` and catch the error to workaround https://github.com/swiftlang/swift-foundation/issues/1125
150
+
do{
151
+
trycopyItem(at: source, to: destination)
152
+
}catchlet error as CocoaError{
153
+
// In Swift 6 on Linux, `FileManager/copyItems(at:to:)` raises an error _after_ successfully copying the files when it's moving over file attributes from the source to the destination.
154
+
// To workaround this issue, we check if the destination exist and the error wasn't that the destination _already_ existed.
155
+
if error.code !=CocoaError.Code.fileWriteFileExists,
156
+
fileExists(atPath: destination.path)
157
+
{
158
+
// Ignore this error.
159
+
// The consequence is that the copied item may have some different attributes (creation date, owner, etc.) compared to the source.
160
+
// These attributes aren't critical for copying input files over to the output documentation archive.
161
+
return
162
+
}
163
+
164
+
// Otherwise, if this was any other error or if the destination file doesn't exist after calling `FileManager/copyItems(at:to:)`, re-throw the error to the caller.
0 commit comments