Use failIfThrows in BackupArchiveExportProgress.prepare
This commit is contained in:
parent
979d64d10a
commit
e72061106f
@ -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,
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user