Make ensureAttachmentIsReencryptable migration resilient to missing attachments

This commit is contained in:
trevor-signal 2024-10-08 17:45:00 -04:00 committed by GitHub
parent a1be616e6f
commit 0e386ef705
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 117 additions and 15 deletions

View file

@ -79,6 +79,9 @@ type MigrationsModuleType = {
deleteSticker: (path: string) => Promise<void>;
deleteTempFile: (path: string) => Promise<void>;
doesAttachmentExist: (path: string) => Promise<boolean>;
ensureAttachmentIsReencryptable: (
attachment: TypesAttachment.LocallySavedAttachment
) => Promise<TypesAttachment.ReencryptableAttachment>;
getAbsoluteAttachmentPath: (path: string) => string;
getAbsoluteAvatarPath: (src: string) => string;
getAbsoluteBadgeImageFilePath: (path: string) => string;
@ -161,6 +164,7 @@ export function initializeMigrations({
createPlaintextReader,
createWriterForNew,
createDoesExist,
ensureAttachmentIsReencryptable,
getAvatarsPath,
getDraftPath,
getDownloadsPath,
@ -291,6 +295,7 @@ export function initializeMigrations({
deleteSticker,
deleteTempFile,
doesAttachmentExist,
ensureAttachmentIsReencryptable,
getAbsoluteAttachmentPath,
getAbsoluteAvatarPath,
getAbsoluteBadgeImageFilePath,
@ -313,6 +318,7 @@ export function initializeMigrations({
processNewAttachment: (attachment: AttachmentType) =>
MessageType.processNewAttachment(attachment, {
writeNewAttachmentData,
ensureAttachmentIsReencryptable,
makeObjectUrl,
revokeObjectUrl,
getImageDimensions,
@ -341,6 +347,8 @@ export function initializeMigrations({
return MessageType.upgradeSchema(message, {
deleteOnDisk,
doesAttachmentExist,
ensureAttachmentIsReencryptable,
getImageDimensions,
getRegionCode,
makeImageThumbnail,
@ -350,7 +358,6 @@ export function initializeMigrations({
revokeObjectUrl,
writeNewAttachmentData,
writeNewStickerData,
logger,
maxVersion,
});
@ -404,6 +411,9 @@ type AttachmentsModuleType = {
name: string;
}) => Promise<null | { fullPath: string; name: string }>;
ensureAttachmentIsReencryptable: (
attachment: TypesAttachment.LocallySavedAttachment
) => Promise<TypesAttachment.ReencryptableAttachment>;
readAndDecryptDataFromDisk: (options: {
absolutePath: string;
keysBase64: string;