Better handling of failed message migration attempts

This commit is contained in:
trevor-signal
2024-11-18 16:35:47 -05:00
committed by GitHub
parent 512dcaad45
commit a068456139
5 changed files with 84 additions and 74 deletions
+3 -3
View File
@@ -5,11 +5,11 @@ import {
type AttachmentType,
mightBeOnBackupTier,
AttachmentVariant,
getAttachmentIdForLogging,
} from '../types/Attachment';
import { downloadAttachment as doDownloadAttachment } from '../textsecure/downloadAttachment';
import { MediaTier } from '../types/AttachmentDownload';
import * as log from '../logging/log';
import { redactGenericText } from './privacy';
import { HTTPError } from '../textsecure/Errors';
import { toLogFormat } from '../types/errors';
import type { ReencryptedAttachmentV2 } from '../AttachmentCrypto';
@@ -25,10 +25,10 @@ export async function downloadAttachment({
variant?: AttachmentVariant;
dependencies?: { downloadAttachmentFromServer: typeof doDownloadAttachment };
}): Promise<ReencryptedAttachmentV2> {
const redactedDigest = redactGenericText(attachment.digest ?? '');
const attachmentId = getAttachmentIdForLogging(attachment);
const variantForLogging =
variant !== AttachmentVariant.Default ? `[${variant}]` : '';
const dataId = `${redactedDigest}${variantForLogging}`;
const dataId = `${attachmentId}${variantForLogging}`;
const logId = `downloadAttachmentUtil(${dataId})`;
const { server } = window.textsecure;
+3 -2
View File
@@ -17,11 +17,11 @@ import {
hasAllOriginalEncryptionInfo,
isReencryptableToSameDigest,
isReencryptableWithNewEncryptionInfo,
getAttachmentIdForLogging,
} from '../types/Attachment';
import { strictAssert } from './assert';
import * as logging from '../logging/log';
import { fromBase64, toBase64 } from '../Bytes';
import { redactGenericText } from './privacy';
import { toLogFormat } from '../types/errors';
/**
@@ -37,7 +37,6 @@ import { toLogFormat } from '../types/errors';
export async function ensureAttachmentIsReencryptable(
attachment: LocallySavedAttachment
): Promise<ReencryptableAttachment> {
const logId = `ensureAttachmentIsReencryptable(digest=${redactGenericText(attachment.digest ?? '')})`;
if (isReencryptableToSameDigest(attachment)) {
return attachment;
}
@@ -54,6 +53,8 @@ export async function ensureAttachmentIsReencryptable(
isReencryptableToSameDigest: true,
};
} catch (e) {
const logId = `ensureAttachmentIsReencryptable(digest=${getAttachmentIdForLogging(attachment)})`;
if (e instanceof ReencryptedDigestMismatchError) {
logging.info(
`${logId}: Unable to reencrypt attachment to original digest; must have had non-zero padding`