@@ -16,7 +16,7 @@ final class FileOpsEngine {
1616
1717 private let panel = FileOpProgressPanel . shared
1818 private let maxConcurrency = 5
19- private let chunkSize = 256 * 1024 // 256 KB
19+ private let chunkSize = 256 * 1024 // 256 KB
2020
2121 private init ( ) {
2222 log. debug ( " [FileOpsEngine] init " )
@@ -55,7 +55,7 @@ final class FileOpsEngine {
5555 let progress = FileOpProgress (
5656 totalFiles: items. count,
5757 totalBytes: totalSize,
58- type: . copy, // reuse for display
58+ type: . copy, // reuse for display
5959 destination: nil
6060 )
6161
@@ -117,12 +117,12 @@ final class FileOpsEngine {
117117 }
118118
119119 switch plan. strategy {
120- case . simple:
121- try await executeSimple ( plan: plan, operation: operation, progress: progress)
122- case . manySmall:
123- try await executeManySmall ( plan: plan, operation: operation, progress: progress)
124- case . fewLarge:
125- try await executeFewLarge ( plan: plan, operation: operation, progress: progress)
120+ case . simple:
121+ try await executeSimple ( plan: plan, operation: operation, progress: progress)
122+ case . manySmall:
123+ try await executeManySmall ( plan: plan, operation: operation, progress: progress)
124+ case . fewLarge:
125+ try await executeFewLarge ( plan: plan, operation: operation, progress: progress)
126126 }
127127
128128 return progress
@@ -140,10 +140,10 @@ final class FileOpsEngine {
140140 let target = UniqueNameGen . resolve ( name: item. lastPathComponent, in: plan. destination)
141141 do {
142142 switch operation {
143- case . copy:
144- try fm. copyItem ( at: item, to: target)
145- case . move:
146- try fm. moveItem ( at: item, to: target)
143+ case . copy:
144+ try fm. copyItem ( at: item, to: target)
145+ case . move:
146+ try fm. moveItem ( at: item, to: target)
147147 }
148148 let size = ( try ? item. resourceValues ( forKeys: [ . fileSizeKey] ) . fileSize) . map ( Int64 . init) ?? 0
149149 progress. fileCompleted ( name: item. lastPathComponent, success: true )
@@ -196,10 +196,10 @@ final class FileOpsEngine {
196196
197197 do {
198198 switch operation {
199- case . copy:
200- try fm. copyItem ( at: entry. url, to: targetURL)
201- case . move:
202- try fm. moveItem ( at: entry. url, to: targetURL)
199+ case . copy:
200+ try fm. copyItem ( at: entry. url, to: targetURL)
201+ case . move:
202+ try fm. moveItem ( at: entry. url, to: targetURL)
203203 }
204204 progress. fileCompleted ( name: entry. url. lastPathComponent, success: true )
205205 progress. add ( bytes: entry. size)
@@ -239,7 +239,7 @@ final class FileOpsEngine {
239239
240240 for entry in fileEntries {
241241 guard !progress. isCancelled else { break }
242- await progress. setCurrentFile ( entry. url. lastPathComponent)
242+ progress. setCurrentFile ( entry. url. lastPathComponent)
243243
244244 let targetURL = UniqueNameGen . resolve (
245245 name: entry. relativePath,
@@ -292,7 +292,7 @@ final class FileOpsEngine {
292292
293293 // MARK: - Stream Copy (256KB chunks)
294294
295- private nonisolated func streamCopy(
295+ private func streamCopy(
296296 from source: URL ,
297297 to destination: URL ,
298298 progress: FileOpProgress
@@ -306,28 +306,29 @@ final class FileOpsEngine {
306306
307307 input. open ( )
308308 output. open ( )
309- defer { input. close ( ) ; output. close ( ) }
309+ defer {
310+ input. close ( )
311+ output. close ( )
312+ }
310313
311314 let bufSize = 256 * 1024
312315 let buffer = UnsafeMutablePointer< UInt8> . allocate( capacity: bufSize)
313316 defer { buffer. deallocate ( ) }
314317
315318 while true {
316- let cancelled = await progress. isCancelled
317- if cancelled { break }
319+ if progress. isCancelled { break }
318320
319321 let bytesRead = input. read ( buffer, maxLength: bufSize)
320322 if bytesRead < 0 {
321323 throw FileOpError . readFailed ( source. path)
322324 }
323- if bytesRead == 0 { break } // EOF
325+ if bytesRead == 0 { break } // EOF
324326
325327 let written = output. write ( buffer, maxLength: bytesRead)
326328 if written < 0 {
327329 throw FileOpError . writeFailed ( destination. path)
328330 }
329-
330- await progress. add ( bytes: Int64 ( written) )
331+ progress. add ( bytes: Int64 ( written) )
331332 }
332333 }
333334
0 commit comments