Skip to content

Commit 3b67d00

Browse files
Update accounting of backed up attachments
1 parent 947ad18 commit 3b67d00

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ts/jobs/AttachmentDownloadManager.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
shouldAttachmentEndUpInRemoteBackup,
3333
getUndownloadedAttachmentSignature,
3434
isIncremental,
35+
hasRequiredInformationForBackup,
3536
} from '../types/Attachment.js';
3637
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
3738
import { 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

Comments
 (0)