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.
This commit is contained in:
Greyson Parrelli
2026-02-23 14:25:07 +00:00
committed by Cody Henthorne
parent 163ece75b2
commit a91aa72fb4

View File

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