@@ -32,6 +32,7 @@ import {
3232 shouldAttachmentEndUpInRemoteBackup ,
3333 getUndownloadedAttachmentSignature ,
3434 isIncremental ,
35+ hasRequiredInformationForBackup ,
3536} from '../types/Attachment.js' ;
3637import type { ReadonlyMessageAttributesType } from '../model-types.d.ts' ;
3738import { getMessageById } from '../messages/getMessageById.js' ;
@@ -294,10 +295,18 @@ export class AttachmentDownloadManager extends JobManager<CoreAttachmentDownload
294295 messageId,
295296 receivedAt,
296297 sentAt,
297- source,
298298 urgency = AttachmentDownloadUrgency . STANDARD ,
299299 } = newJobData ;
300300
301+ let { source } = newJobData ;
302+
303+ if (
304+ source === AttachmentDownloadSource . BACKUP_IMPORT_WITH_MEDIA &&
305+ ! hasRequiredInformationForBackup ( attachment )
306+ ) {
307+ source = AttachmentDownloadSource . BACKUP_IMPORT_NO_MEDIA ;
308+ }
309+
301310 const logId = `AttachmentDownloadManager/addJob(${ sentAt } .${ attachmentType } )` ;
302311
303312 // For non-media-enabled backups, we will skip queueing download for old attachments
@@ -325,9 +334,10 @@ export class AttachmentDownloadManager extends JobManager<CoreAttachmentDownload
325334 // download from the transit tier, which would be a slightly smaller size)
326335 ciphertextSize : getAttachmentCiphertextSize ( {
327336 unpaddedPlaintextSize : attachment . size ,
328- mediaTier : AttachmentDownloadSource . BACKUP_IMPORT_WITH_MEDIA
329- ? MediaTier . BACKUP
330- : MediaTier . STANDARD ,
337+ mediaTier :
338+ source === AttachmentDownloadSource . BACKUP_IMPORT_WITH_MEDIA
339+ ? MediaTier . BACKUP
340+ : MediaTier . STANDARD ,
331341 } ) ,
332342 contentType : attachment . contentType ,
333343 attachmentSignature : getUndownloadedAttachmentSignature ( attachment ) ,
0 commit comments