From f2ebedb36a2e91f213521aa3ab3d3b496b6b9e15 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Tue, 23 Sep 2025 09:58:24 -0400 Subject: [PATCH] The formatter changed its mind (#3379) --- .github/workflows/pull_request.yml | 2 + .../AsyncSequences/NIOAsyncWriter.swift | 8 +- Sources/NIOCore/EventLoopFuture.swift | 7 +- Sources/NIOFileSystem/FileSystem.swift | 90 ++++++++++--------- .../NIOFileSystem/FileSystemProtocol.swift | 36 ++++---- .../Internal/ParallelDirCopy.swift | 18 ++-- Sources/NIOPosix/Bootstrap.swift | 63 +++++++------ Sources/NIOPosix/HappyEyeballs.swift | 7 +- .../PosixSingletons+ConcurrencyTakeOver.swift | 7 +- Sources/NIOPosix/RawSocketBootstrap.swift | 21 +++-- Sources/_NIOFileSystem/FileSystem.swift | 90 ++++++++++--------- .../_NIOFileSystem/FileSystemProtocol.swift | 54 ++++++----- .../Internal/ParallelDirCopy.swift | 18 ++-- .../SyscallAbstractionLayerContext.swift | 33 +++---- 14 files changed, 254 insertions(+), 200 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f171e1de5..bc91f548a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,6 +10,8 @@ jobs: uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: license_header_check_project_name: "SwiftNIO" + # Workaround https://github.com/swiftlang/swift-docc/issues/1280 + docs_check_container_image: "swift:6.1-noble" unit-tests: name: Unit tests diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift index 185a27e63..d249ed86a 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift @@ -510,7 +510,7 @@ extension NIOAsyncWriter { switch action { case .resumeContinuations(let suspendedYields): for yield in suspendedYields { - yield .continuation.resume(returning: .retry) + yield.continuation.resume(returning: .retry) } case .none: @@ -675,7 +675,7 @@ extension NIOAsyncWriter { case .resumeContinuations(let suspendedYields): for yield in suspendedYields { - yield .continuation.resume(returning: .retry) + yield.continuation.resume(returning: .retry) } case .none: @@ -695,7 +695,7 @@ extension NIOAsyncWriter { switch action { case .resumeContinuationsWithError(let suspendedYields, let error): for yield in suspendedYields { - yield .continuation.resume(throwing: error) + yield.continuation.resume(throwing: error) } case .none: @@ -712,7 +712,7 @@ extension NIOAsyncWriter { case .resumeContinuations(let suspendedYields): for yield in suspendedYields { - yield .continuation.resume(returning: .retry) + yield.continuation.resume(returning: .retry) } return } diff --git a/Sources/NIOCore/EventLoopFuture.swift b/Sources/NIOCore/EventLoopFuture.swift index 985c9cc8a..3132e1a10 100644 --- a/Sources/NIOCore/EventLoopFuture.swift +++ b/Sources/NIOCore/EventLoopFuture.swift @@ -755,9 +755,10 @@ extension EventLoopFuture { ) -> EventLoopFuture { self._flatMapResult(body) } - @usableFromInline typealias FlatMapResultCallback = @Sendable (Value) -> Result< - NewValue, SomeError - > + @usableFromInline typealias FlatMapResultCallback = + @Sendable (Value) -> Result< + NewValue, SomeError + > @inlinable func _flatMapResult( diff --git a/Sources/NIOFileSystem/FileSystem.swift b/Sources/NIOFileSystem/FileSystem.swift index f415be1e6..b54e6cb28 100644 --- a/Sources/NIOFileSystem/FileSystem.swift +++ b/Sources/NIOFileSystem/FileSystem.swift @@ -314,14 +314,16 @@ public struct FileSystem: Sendable, FileSystemProtocol { at sourcePath: NIOFilePath, to destinationPath: NIOFilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: NIOFilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: NIOFilePath + ) async -> Bool ) async throws { guard let info = try await self.info(forFileAt: sourcePath, infoAboutSymbolicLink: true) else { @@ -897,14 +899,16 @@ extension FileSystem { private func prepareDirectoryForRecusiveCopy( from sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws -> [DirCopyItem] { try await self.withDirectoryHandle(atPath: NIOFilePath(sourcePath)) { dir in // Grab the directory info to copy permissions. @@ -987,14 +991,16 @@ extension FileSystem { private func copyDirectorySequential( from sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { // Strategy: find all needed items to copy/recurse into while the directory is open; defer // actual copying and recursion until after the source directory has been closed to avoid @@ -1066,14 +1072,16 @@ extension FileSystem { from sourcePath: FilePath, to destinationPath: FilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { switch copyStrategy.wrapped { case .sequential: @@ -1110,14 +1118,16 @@ extension FileSystem { from: DirectoryEntry, to: FilePath, yield: @Sendable ([DirCopyItem]) -> Void, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { switch from.type { case .regular: diff --git a/Sources/NIOFileSystem/FileSystemProtocol.swift b/Sources/NIOFileSystem/FileSystemProtocol.swift index fc7539b6a..4b98032ac 100644 --- a/Sources/NIOFileSystem/FileSystemProtocol.swift +++ b/Sources/NIOFileSystem/FileSystemProtocol.swift @@ -233,14 +233,16 @@ public protocol FileSystemProtocol: Sendable { at sourcePath: NIOFilePath, to destinationPath: NIOFilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: NIOFilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: NIOFilePath + ) async -> Bool ) async throws /// Deletes the file or directory (and its contents) at `path`. @@ -516,14 +518,16 @@ extension FileSystemProtocol { public func copyItem( at sourcePath: NIOFilePath, to destinationPath: NIOFilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: NIOFilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: NIOFilePath + ) async -> Bool ) async throws { try await self.copyItem( at: sourcePath, diff --git a/Sources/NIOFileSystem/Internal/ParallelDirCopy.swift b/Sources/NIOFileSystem/Internal/ParallelDirCopy.swift index fafd58419..029dd77ac 100644 --- a/Sources/NIOFileSystem/Internal/ParallelDirCopy.swift +++ b/Sources/NIOFileSystem/Internal/ParallelDirCopy.swift @@ -33,14 +33,16 @@ extension FileSystem { from sourcePath: FilePath, to destinationPath: FilePath, maxConcurrentOperations: Int, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { // Implemented with NIOAsyncSequenceProducer rather than AsyncStream. It is approximately // the same speed in the best case, but has significantly less variance. diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index e5dc82dfa..a79148ee6 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -1407,9 +1407,10 @@ extension ClientBootstrap { port: Int, eventLoop: EventLoop, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let resolver = self.resolver @@ -1455,9 +1456,10 @@ extension ClientBootstrap { eventLoop: EventLoop, socket: NIOBSDSocket.Handle, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let channel = try SocketChannel(eventLoop: eventLoop as! SelectableEventLoop, socket: socket) @@ -1481,9 +1483,10 @@ extension ClientBootstrap { eventLoop: EventLoop, protocolFamily: NIOBSDSocket.ProtocolFamily, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - >, + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + >, _ body: @escaping @Sendable (Channel) -> EventLoopFuture ) -> EventLoopFuture<(Channel, PostRegistrationTransformationResult)> { let channel: SocketChannel @@ -1514,9 +1517,10 @@ extension ClientBootstrap { channelOptions: ChannelOptions.Storage, bindTarget: SocketAddress?, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - >, + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + >, _ body: @escaping @Sendable (Channel) -> EventLoopFuture ) -> EventLoopFuture<(Channel, PostRegistrationTransformationResult)> { let channel: SocketChannel @@ -1550,9 +1554,10 @@ extension ClientBootstrap { channel: SocketChannel, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, registration: @escaping @Sendable (SocketChannel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) -> EventLoopFuture { Self.initializeAndRegisterChannel( channel: channel, @@ -1576,9 +1581,10 @@ extension ClientBootstrap { bindTarget: SocketAddress?, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, registration: @escaping @Sendable (SocketChannel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) -> EventLoopFuture { let channelInitializer = { @Sendable channel in bootstrapChannelInitializer(channel).hop(to: channel.eventLoop) @@ -2097,9 +2103,10 @@ extension DatagramBootstrap { private func connect0( makeSocketAddress: () throws -> SocketAddress, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let address = try makeSocketAddress() let subtype = self.proto @@ -2128,9 +2135,10 @@ extension DatagramBootstrap { private func bind0( makeSocketAddress: () throws -> SocketAddress, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let address = try makeSocketAddress() let subtype = self.proto @@ -2163,9 +2171,10 @@ extension DatagramBootstrap { makeChannel: (_ eventLoop: SelectableEventLoop) throws -> DatagramChannel, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, registration: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) -> EventLoopFuture { let eventLoop = self.group.next() let bootstrapChannelInitializer = diff --git a/Sources/NIOPosix/HappyEyeballs.swift b/Sources/NIOPosix/HappyEyeballs.swift index 0e694e8c1..10bc3b09d 100644 --- a/Sources/NIOPosix/HappyEyeballs.swift +++ b/Sources/NIOPosix/HappyEyeballs.swift @@ -207,9 +207,10 @@ internal struct HappyEyeballsConnector: Sendable connectTimeout: TimeAmount, resolutionDelay: TimeAmount = .milliseconds(50), connectionDelay: TimeAmount = .milliseconds(250), - channelBuilderCallback: @escaping @Sendable (EventLoop, NIOBSDSocket.ProtocolFamily) -> EventLoopFuture< - (Channel, ChannelBuilderResult) - > + channelBuilderCallback: + @escaping @Sendable (EventLoop, NIOBSDSocket.ProtocolFamily) -> EventLoopFuture< + (Channel, ChannelBuilderResult) + > ) { self.resolver = resolver self.loop = loop diff --git a/Sources/NIOPosix/PosixSingletons+ConcurrencyTakeOver.swift b/Sources/NIOPosix/PosixSingletons+ConcurrencyTakeOver.swift index aa70894e0..cc79c676d 100644 --- a/Sources/NIOPosix/PosixSingletons+ConcurrencyTakeOver.swift +++ b/Sources/NIOPosix/PosixSingletons+ConcurrencyTakeOver.swift @@ -49,9 +49,10 @@ extension NIOSingletons { return false } - typealias ConcurrencyEnqueueGlobalHook = @convention(thin) ( - UnownedJob, @convention(thin) (UnownedJob) -> Void - ) -> Void + typealias ConcurrencyEnqueueGlobalHook = + @convention(thin) ( + UnownedJob, @convention(thin) (UnownedJob) -> Void + ) -> Void guard _haveWeTakenOverTheConcurrencyPool.compareExchange( diff --git a/Sources/NIOPosix/RawSocketBootstrap.swift b/Sources/NIOPosix/RawSocketBootstrap.swift index 3389bb080..7b16f48c2 100644 --- a/Sources/NIOPosix/RawSocketBootstrap.swift +++ b/Sources/NIOPosix/RawSocketBootstrap.swift @@ -260,9 +260,10 @@ extension NIORawSocketBootstrap { host: String, ipProtocol: NIOIPProtocol, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let address = try SocketAddress.makeAddressResolvingHost(host, port: 0) @@ -292,9 +293,10 @@ extension NIORawSocketBootstrap { host: String, ipProtocol: NIOIPProtocol, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) async throws -> PostRegistrationTransformationResult { let address = try SocketAddress.makeAddressResolvingHost(host, port: 0) @@ -328,9 +330,10 @@ extension NIORawSocketBootstrap { makeChannel: (_ eventLoop: SelectableEventLoop) throws -> DatagramChannel, channelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture, registration: @escaping @Sendable (Channel) -> EventLoopFuture, - postRegisterTransformation: @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< - PostRegistrationTransformationResult - > + postRegisterTransformation: + @escaping @Sendable (ChannelInitializerResult, EventLoop) -> EventLoopFuture< + PostRegistrationTransformationResult + > ) -> EventLoopFuture { let eventLoop = self.group.next() let bootstrapInitializer = self.channelInitializer ?? { @Sendable _ in eventLoop.makeSucceededFuture(()) } diff --git a/Sources/_NIOFileSystem/FileSystem.swift b/Sources/_NIOFileSystem/FileSystem.swift index 71f4839c9..8b7df2bb1 100644 --- a/Sources/_NIOFileSystem/FileSystem.swift +++ b/Sources/_NIOFileSystem/FileSystem.swift @@ -314,14 +314,16 @@ public struct FileSystem: Sendable, FileSystemProtocol { at sourcePath: FilePath, to destinationPath: FilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { guard let info = try await self.info(forFileAt: sourcePath, infoAboutSymbolicLink: true) else { @@ -911,14 +913,16 @@ extension FileSystem { private func prepareDirectoryForRecusiveCopy( from sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws -> [DirCopyItem] { try await self.withDirectoryHandle(atPath: sourcePath) { dir in // Grab the directory info to copy permissions. @@ -1001,14 +1005,16 @@ extension FileSystem { private func copyDirectorySequential( from sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { // Strategy: find all needed items to copy/recurse into while the directory is open; defer // actual copying and recursion until after the source directory has been closed to avoid @@ -1080,14 +1086,16 @@ extension FileSystem { from sourcePath: FilePath, to destinationPath: FilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { switch copyStrategy.wrapped { case .sequential: @@ -1124,14 +1132,16 @@ extension FileSystem { from: DirectoryEntry, to: FilePath, yield: @Sendable ([DirCopyItem]) -> Void, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { switch from.type { case .regular: diff --git a/Sources/_NIOFileSystem/FileSystemProtocol.swift b/Sources/_NIOFileSystem/FileSystemProtocol.swift index 6b122f3be..2c7844e03 100644 --- a/Sources/_NIOFileSystem/FileSystemProtocol.swift +++ b/Sources/_NIOFileSystem/FileSystemProtocol.swift @@ -233,14 +233,16 @@ public protocol FileSystemProtocol: Sendable { at sourcePath: FilePath, to destinationPath: FilePath, strategy copyStrategy: CopyStrategy, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws /// Deletes the file or directory (and its contents) at `path`. @@ -520,14 +522,16 @@ extension FileSystemProtocol { public func copyItem( at sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyFile: @escaping @Sendable ( - _ source: FilePath, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyFile: + @escaping @Sendable ( + _ source: FilePath, + _ destination: FilePath + ) async -> Bool ) async throws { try await self.copyItem( at: sourcePath, @@ -569,14 +573,16 @@ extension FileSystemProtocol { public func copyItem( at sourcePath: FilePath, to destinationPath: FilePath, - shouldProceedAfterError: @escaping @Sendable ( - _ source: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { try await self.copyItem( at: sourcePath, diff --git a/Sources/_NIOFileSystem/Internal/ParallelDirCopy.swift b/Sources/_NIOFileSystem/Internal/ParallelDirCopy.swift index ce793264a..ae9d30f6f 100644 --- a/Sources/_NIOFileSystem/Internal/ParallelDirCopy.swift +++ b/Sources/_NIOFileSystem/Internal/ParallelDirCopy.swift @@ -33,14 +33,16 @@ extension FileSystem { from sourcePath: FilePath, to destinationPath: FilePath, maxConcurrentOperations: Int, - shouldProceedAfterError: @escaping @Sendable ( - _ entry: DirectoryEntry, - _ error: Error - ) async throws -> Void, - shouldCopyItem: @escaping @Sendable ( - _ source: DirectoryEntry, - _ destination: FilePath - ) async -> Bool + shouldProceedAfterError: + @escaping @Sendable ( + _ entry: DirectoryEntry, + _ error: Error + ) async throws -> Void, + shouldCopyItem: + @escaping @Sendable ( + _ source: DirectoryEntry, + _ destination: FilePath + ) async -> Bool ) async throws { // Implemented with NIOAsyncSequenceProducer rather than AsyncStream. It is approximately // the same speed in the best case, but has significantly less variance. diff --git a/Tests/NIOPosixTests/SyscallAbstractionLayerContext.swift b/Tests/NIOPosixTests/SyscallAbstractionLayerContext.swift index 207bf725b..bf900a203 100644 --- a/Tests/NIOPosixTests/SyscallAbstractionLayerContext.swift +++ b/Tests/NIOPosixTests/SyscallAbstractionLayerContext.swift @@ -47,11 +47,12 @@ struct SALContext { func runSALOnEventLoop( file: StaticString = #filePath, line: UInt = #line, - body: @escaping @Sendable ( - _ eventLoop: SelectableEventLoop, - _ kernelToUser: LockedBox, - _ userToKernal: LockedBox - ) throws -> Result, + body: + @escaping @Sendable ( + _ eventLoop: SelectableEventLoop, + _ kernelToUser: LockedBox, + _ userToKernal: LockedBox + ) throws -> Result, syscallAssertions: (SyscallAssertions) throws -> Void ) throws -> Result { let box = LockedBox>() @@ -81,11 +82,12 @@ struct SALContext { func runSALOnEventLoopAndWait( file: StaticString = #filePath, line: UInt = #line, - body: @escaping @Sendable ( - _ eventLoop: SelectableEventLoop, - _ kernelToUser: LockedBox, - _ userToKernal: LockedBox - ) throws -> EventLoopFuture, + body: + @escaping @Sendable ( + _ eventLoop: SelectableEventLoop, + _ kernelToUser: LockedBox, + _ userToKernal: LockedBox + ) throws -> EventLoopFuture, syscallAssertions: (SyscallAssertions) throws -> Void ) throws -> Result { let result = try self.runSALOnEventLoop(body: body, syscallAssertions: syscallAssertions) @@ -95,11 +97,12 @@ struct SALContext { func runSALOnEventLoop( file: StaticString = #filePath, line: UInt = #line, - body: @escaping @Sendable ( - _ eventLoop: SelectableEventLoop, - _ kernelToUser: LockedBox, - _ userToKernal: LockedBox - ) throws -> Result + body: + @escaping @Sendable ( + _ eventLoop: SelectableEventLoop, + _ kernelToUser: LockedBox, + _ userToKernal: LockedBox + ) throws -> Result ) throws -> Result { try self.runSALOnEventLoop(file: file, line: line, body: body) { _ in } }