From 95319d13b7aea9a344a38ea00e2e4c0ece46c41e Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 29 Jun 2026 17:06:14 +0300 Subject: [PATCH] Make the zip and file attaching bug report service steps concurrent --- .../Sources/Services/BugReport/BugReportService.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ElementX/Sources/Services/BugReport/BugReportService.swift b/ElementX/Sources/Services/BugReport/BugReportService.swift index 261bb3db2..54d03e919 100644 --- a/ElementX/Sources/Services/BugReport/BugReportService.swift +++ b/ElementX/Sources/Services/BugReport/BugReportService.swift @@ -204,6 +204,7 @@ class BugReportService: NSObject, BugReportServiceProtocol { } } + @concurrent private func zipFiles(_ logFiles: [URL]) async -> Logs { MXLog.info("zipFiles") @@ -211,7 +212,7 @@ class BugReportService: NSObject, BugReportServiceProtocol { for url in logFiles { do { - try attachFile(at: url, to: &compressedLogs) + try await attachFile(at: url, to: &compressedLogs) } catch { MXLog.error("Failed to compress log at \(url)") // Continue so that other logs can still be sent. @@ -224,7 +225,8 @@ class BugReportService: NSObject, BugReportServiceProtocol { } /// Zips a file creating chunks based on 10MB inputs. - private func attachFile(at url: URL, to zippedFiles: inout Logs) throws { + @concurrent + private func attachFile(at url: URL, to zippedFiles: inout Logs) async throws { let fileHandle = try FileHandle(forReadingFrom: url) while let data = try fileHandle.readToEnd() { @@ -235,7 +237,7 @@ class BugReportService: NSObject, BugReportServiceProtocol { try? FileManager.default.removeItem(at: zippedURL) try zippedData.write(to: zippedURL) - zippedFiles.appendFile(at: zippedURL, zippedSize: zippedData.count, originalSize: data.count) + await zippedFiles.appendFile(at: zippedURL, zippedSize: zippedData.count, originalSize: data.count) } } }