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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 84 additions and 74 deletions

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`