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 8b981a3e9c..a0adb23d28 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt @@ -123,9 +123,18 @@ class CopyAttachmentToArchiveJob private constructor(private val attachmentId: A return Result.success() } - if (isCanceled) { - Log.w(TAG, "[$attachmentId] Canceled. Refusing to proceed.") - return Result.failure() + if (attachment.cdn !in ALLOWED_SOURCE_CDNS) { + Log.i(TAG, "[$attachmentId] Attachment CDN (${attachment.cdn}) is not in allowed source CDNs. Enqueueing an upload job instead.") + setArchiveTransferStateWithDelayedNotification(attachmentId, AttachmentTable.ArchiveTransferState.NONE) + AppDependencies.jobManager.add(UploadAttachmentToArchiveJob(attachmentId, canReuseUpload = false)) + return Result.success() + } + + if (attachment.remoteLocation == null) { + Log.i(TAG, "[$attachmentId] Attachment has no remote location. Enqueueing an upload job instead.") + setArchiveTransferStateWithDelayedNotification(attachmentId, AttachmentTable.ArchiveTransferState.NONE) + AppDependencies.jobManager.add(UploadAttachmentToArchiveJob(attachmentId, canReuseUpload = false)) + return Result.success() } if (attachment.archiveTransferState == AttachmentTable.ArchiveTransferState.NONE) { @@ -134,6 +143,11 @@ class CopyAttachmentToArchiveJob private constructor(private val attachmentId: A return Result.success() } + if (isCanceled) { + Log.w(TAG, "[$attachmentId] Canceled. Refusing to proceed.") + return Result.failure() + } + val result = when (val archiveResult = BackupRepository.copyAttachmentToArchive(attachment)) { is NetworkResult.Success -> { Log.i(TAG, "[$attachmentId] Successfully copied the archive tier.")