Mark attachment 404's as permanent failures.

This commit is contained in:
Greyson Parrelli
2026-02-20 19:18:51 +00:00
committed by Cody Henthorne
parent 121f0c6134
commit 65a30cf2a7
2 changed files with 9 additions and 3 deletions

View File

@@ -153,7 +153,7 @@ abstract class Attachment(
* Denotes whether the media for the given attachment is no longer available for download.
*/
val isMediaNoLongerAvailableForDownload: Boolean
get() = isPermanentlyFailed && uploadTimestamp.milliseconds > 30.days
get() = isPermanentlyFailed && (System.currentTimeMillis().milliseconds - uploadTimestamp.milliseconds) > 30.days
val isSticker: Boolean
get() = stickerLocator != null

View File

@@ -441,6 +441,8 @@ class RestoreAttachmentJob private constructor(
if (attachment.dataHash != null) {
maybePostFailedToDownloadFromArchiveAndTransitNotification()
}
markPermanentlyFailed(attachmentId)
return
} else if (SignalStore.backup.backsUpMedia && attachment.remoteLocation.isNotNullOrBlank()) {
Log.w(TAG, "[$attachmentId] Failed to download attachment from the archive CDN! Retrying download from transit CDN. hasPlaintextHash: ${attachment.dataHash != null}")
if (attachment.dataHash != null) {
@@ -453,8 +455,12 @@ class RestoreAttachmentJob private constructor(
if (attachment.dataHash != null) {
maybePostFailedToDownloadFromArchiveAndTransitNotification()
}
markPermanentlyFailed(attachmentId)
return
} else if (attachment.remoteLocation.isNotNullOrBlank()) {
Log.w(TAG, "[$attachmentId] Failed to restore an attachment for a free tier user. Likely just older than 45 days.")
markPermanentlyFailed(attachmentId)
return
}
}
401 -> {
@@ -491,9 +497,9 @@ class RestoreAttachmentJob private constructor(
SignalDatabase.attachments.clearIncrementalMacsForAttachmentAndAnyDuplicates(attachmentId, attachment.remoteKey, attachment.dataHash)
}
markFailed(attachmentId)
} finally {
attachmentFile.delete()
}
attachmentFile.delete()
}
private fun markFailed(attachmentId: AttachmentId) {