diff --git a/ts/jobs/AttachmentDownloadManager.ts b/ts/jobs/AttachmentDownloadManager.ts index 85989a90b2..325d78b1ed 100644 --- a/ts/jobs/AttachmentDownloadManager.ts +++ b/ts/jobs/AttachmentDownloadManager.ts @@ -751,7 +751,7 @@ export async function runDownloadAttachmentJobInner({ !preferBackupThumbnail ) { log.error( - `${logId}: failed to download fullsize attachment, falling back to thumbnail`, + `${logId}: failed to download fullsize attachment, falling back to backup thumbnail`, Errors.toLogFormat(error) ); try { diff --git a/ts/util/downloadAttachment.ts b/ts/util/downloadAttachment.ts index 497fbf62c5..f1a4a9cb10 100644 --- a/ts/util/downloadAttachment.ts +++ b/ts/util/downloadAttachment.ts @@ -90,18 +90,29 @@ export async function downloadAttachment({ } ); } catch (error) { + const shouldFallbackToTransitTier = + variant !== AttachmentVariant.ThumbnailFromBackup; + if (error instanceof HTTPError && error.code === 404) { // This is an expected occurrence if restoring from a backup before the // attachment has been moved to the backup tier - log.warn(`${logId}: attachment not found on backup CDN`); + log.warn( + `${logId}: attachment not found on backup CDN`, + shouldFallbackToTransitTier ? 'will try transit tier' : '' + ); } else { // We also just log this error instead of throwing, since we want to still try to // find it on the attachment tier. log.error( - `${logId}: error when downloading from backup CDN; will try transit tier`, + `${logId}: error when downloading from backup CDN`, + shouldFallbackToTransitTier ? 'will try transit tier' : '', toLogFormat(error) ); } + + if (!shouldFallbackToTransitTier) { + throw error; + } } }