mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Better handling of failed message migration attempts
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user