mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 02:58:45 +00:00
Guard against invalid attachment states when copying to archive.
Fixes #14461
This commit is contained in:
committed by
jeffrey-signal
parent
706d89db87
commit
30e43e99fc
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user