Update accounting of backed up attachments

This commit is contained in:
trevor-signal
2025-10-01 13:52:04 -04:00
committed by GitHub
parent 947ad18020
commit 3b67d00c85

View File

@@ -32,6 +32,7 @@ import {
shouldAttachmentEndUpInRemoteBackup,
getUndownloadedAttachmentSignature,
isIncremental,
hasRequiredInformationForBackup,
} from '../types/Attachment.js';
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
import { getMessageById } from '../messages/getMessageById.js';
@@ -294,10 +295,18 @@ export class AttachmentDownloadManager extends JobManager<CoreAttachmentDownload
messageId,
receivedAt,
sentAt,
source,
urgency = AttachmentDownloadUrgency.STANDARD,
} = newJobData;
let { source } = newJobData;
if (
source === AttachmentDownloadSource.BACKUP_IMPORT_WITH_MEDIA &&
!hasRequiredInformationForBackup(attachment)
) {
source = AttachmentDownloadSource.BACKUP_IMPORT_NO_MEDIA;
}
const logId = `AttachmentDownloadManager/addJob(${sentAt}.${attachmentType})`;
// For non-media-enabled backups, we will skip queueing download for old attachments
@@ -325,7 +334,8 @@ export class AttachmentDownloadManager extends JobManager<CoreAttachmentDownload
// download from the transit tier, which would be a slightly smaller size)
ciphertextSize: getAttachmentCiphertextSize({
unpaddedPlaintextSize: attachment.size,
mediaTier: AttachmentDownloadSource.BACKUP_IMPORT_WITH_MEDIA
mediaTier:
source === AttachmentDownloadSource.BACKUP_IMPORT_WITH_MEDIA
? MediaTier.BACKUP
: MediaTier.STANDARD,
}),