From e72061106f7adb53b101fb292d0582f0e48a03fd Mon Sep 17 00:00:00 2001 From: Sasha Weiss Date: Mon, 18 May 2026 15:20:36 -0700 Subject: [PATCH] Use failIfThrows in BackupArchiveExportProgress.prepare --- .../Archiving/BackupArchiveManagerImpl.swift | 2 +- .../Archiving/BackupArchiveProgress.swift | 29 ++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/SignalServiceKit/Backups/Archiving/BackupArchiveManagerImpl.swift b/SignalServiceKit/Backups/Archiving/BackupArchiveManagerImpl.swift index 297b3e6fba..a72b18dc7f 100644 --- a/SignalServiceKit/Backups/Archiving/BackupArchiveManagerImpl.swift +++ b/SignalServiceKit/Backups/Archiving/BackupArchiveManagerImpl.swift @@ -393,7 +393,7 @@ public class BackupArchiveManagerImpl: BackupArchiveManager { withLabel: "Export Backup: Oversize Text Attachments", unitCount: 5, ) - exportProgress = try await .prepare( + exportProgress = await .prepare( sink: await progressSink.addChild( withLabel: "Export Backup: Export Frames", unitCount: 95, diff --git a/SignalServiceKit/Backups/Archiving/BackupArchiveProgress.swift b/SignalServiceKit/Backups/Archiving/BackupArchiveProgress.swift index 21779b299d..183fef367e 100644 --- a/SignalServiceKit/Backups/Archiving/BackupArchiveProgress.swift +++ b/SignalServiceKit/Backups/Archiving/BackupArchiveProgress.swift @@ -14,24 +14,19 @@ public struct BackupArchiveExportProgress { public static func prepare( sink: OWSProgressSink, db: any DB, - ) async throws -> Self { - var estimatedFrameCount = try db.read { tx in - // Get all the major things we iterate over. It doesn't have - // to be perfect; we'll skip some of these and besides they're - // all weighted evenly. Its just an estimate. - return try - SignalRecipient.fetchCount(tx.database) - + TSThread.fetchCount(tx.database) - + InteractionRecord.fetchCount(tx.database) - + CallLinkRecord.fetchCount(tx.database) - + StickerPackRecord.fetchCount(tx.database) + ) async -> Self { + let estimatedFrameCount = failIfThrows { + try db.read { tx in + // Get all the major things we iterate over. It doesn't have + // to be perfect; we'll skip some of these and besides they're + // all weighted evenly. Its just an estimate. + return try SignalRecipient.fetchCount(tx.database) + + TSThread.fetchCount(tx.database) + + InteractionRecord.fetchCount(tx.database) + + CallLinkRecord.fetchCount(tx.database) + + StickerPackRecord.fetchCount(tx.database) + } } - // Add a fixed extra amount for: - // * header frame - // * self recipient - // * account data frame - // * release notes channel - estimatedFrameCount += 4 let progressSource = await sink.addSource( withLabel: "Backup Export",