From a91aa72fb4fcbb99eb872b78cf8f67bb21909a00 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 23 Feb 2026 14:25:07 +0000 Subject: [PATCH] Guard against missing integrity check in CopyAttachmentToArchiveJob. Add a check for hadIntegrityCheckPerformed() before attempting to copy an attachment to the archive. If the attachment's download has failed (transferState == FAILED), requireMediaName() would throw an IllegalArgumentException because the integrity check was never completed. The fix resets the archive transfer state to NONE and skips, allowing a future successful download to re-trigger archiving. --- .../securesms/jobs/CopyAttachmentToArchiveJob.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt index 94d0ea3735..531b7e3fef 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt @@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment import org.thoughtcrime.securesms.backup.ArchiveUploadProgress import org.thoughtcrime.securesms.backup.v2.ArchiveDatabaseExecutor import org.thoughtcrime.securesms.backup.v2.BackupRepository +import org.thoughtcrime.securesms.backup.v2.hadIntegrityCheckPerformed import org.thoughtcrime.securesms.database.AttachmentTable import org.thoughtcrime.securesms.database.SignalDatabase import org.thoughtcrime.securesms.dependencies.AppDependencies @@ -133,6 +134,12 @@ class CopyAttachmentToArchiveJob private constructor(private val attachmentId: A return Result.success() } + if (!attachment.hadIntegrityCheckPerformed()) { + Log.w(TAG, "[$attachmentId]$mediaIdLog Attachment has not had its integrity check performed yet (transferState: ${attachment.transferState}). Resetting transfer state to none and skipping.") + setArchiveTransferStateWithDelayedNotification(attachmentId, AttachmentTable.ArchiveTransferState.NONE) + return Result.success() + } + if (attachment.cdn !in ALLOWED_SOURCE_CDNS) { Log.i(TAG, "[$attachmentId]$mediaIdLog Attachment CDN (${attachment.cdn}) is not in allowed source CDNs. Enqueueing an upload job instead.") setArchiveTransferStateWithDelayedNotification(attachmentId, AttachmentTable.ArchiveTransferState.NONE)