From 0f0c3e6fc69532bae35adae50ab52586ec9e006d Mon Sep 17 00:00:00 2001 From: Max Radermacher Date: Wed, 3 Jun 2026 12:12:08 -0500 Subject: [PATCH] Use failIfThrows in place of forced unwraps --- .../OrphanedBackupAttachmentScheduler.swift | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/SignalServiceKit/Backups/Attachments/OrphanedBackupAttachmentScheduler.swift b/SignalServiceKit/Backups/Attachments/OrphanedBackupAttachmentScheduler.swift index 6ef53979c9..c55563096e 100644 --- a/SignalServiceKit/Backups/Attachments/OrphanedBackupAttachmentScheduler.swift +++ b/SignalServiceKit/Backups/Attachments/OrphanedBackupAttachmentScheduler.swift @@ -53,13 +53,16 @@ public class OrphanedBackupAttachmentSchedulerImpl: OrphanedBackupAttachmentSche withMediaName mediaName: String, tx: DBWriteTransaction, ) { - try! OrphanedBackupAttachment - .filter(Column(OrphanedBackupAttachment.CodingKeys.mediaName) == mediaName) - .deleteAll(tx.database) + failIfThrows { + try OrphanedBackupAttachment + .filter(Column(OrphanedBackupAttachment.CodingKeys.mediaName) == mediaName) + .deleteAll(tx.database) + } let mediaKey = accountKeyStore.getOrGenerateMediaRootBackupKey(tx: tx) for type in OrphanedBackupAttachment.SizeType.allCases { + let mediaId: Data do { - let mediaId = try mediaKey.deriveMediaId( + mediaId = try mediaKey.deriveMediaId( { switch type { case .fullsize: @@ -70,13 +73,15 @@ public class OrphanedBackupAttachmentSchedulerImpl: OrphanedBackupAttachmentSche } }(), ) - try! OrphanedBackupAttachment - .filter(Column(OrphanedBackupAttachment.CodingKeys.mediaId) == mediaId) - .deleteAll(tx.database) } catch { owsFailDebug("Unexpected encryption material error") + continue + } + failIfThrows { + try OrphanedBackupAttachment + .filter(Column(OrphanedBackupAttachment.CodingKeys.mediaId) == mediaId) + .deleteAll(tx.database) } - } }