Use failIfThrows in BackupArchiveExportProgress.prepare

This commit is contained in:
Sasha Weiss 2026-05-18 15:20:36 -07:00 committed by GitHub
parent 979d64d10a
commit e72061106f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 18 deletions

View File

@ -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,

View File

@ -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",