Deduplicate incoming attachments on disk

This commit is contained in:
trevor-signal
2026-02-05 14:48:31 -05:00
committed by GitHub
parent 85cc412b40
commit 834f0c7775
51 changed files with 1727 additions and 560 deletions

View File

@@ -21,7 +21,7 @@ import { DataReader, DataWriter } from '../sql/Client.preload.js';
import { getConversation } from '../util/getConversation.preload.js';
import {
copyAttachmentIntoTempDirectory,
deleteAttachmentData,
maybeDeleteAttachmentFile,
doesAttachmentExist,
getAbsoluteAttachmentPath,
getAbsoluteTempPath,
@@ -3691,7 +3691,7 @@ export class ConversationModel {
const message = window.MessageCache.getById(notificationId);
if (message) {
await DataWriter.removeMessage(message.id, {
await DataWriter.removeMessageById(message.id, {
cleanupMessages,
});
}
@@ -3734,7 +3734,7 @@ export class ConversationModel {
const message = window.MessageCache.getById(notificationId);
if (message) {
await DataWriter.removeMessage(message.id, {
await DataWriter.removeMessageById(message.id, {
cleanupMessages,
});
}
@@ -4214,7 +4214,7 @@ export class ConversationModel {
if (preview && preview.length && !isForwarding) {
attachments.forEach(attachment => {
if (attachment.path) {
void deleteAttachmentData(attachment.path);
drop(maybeDeleteAttachmentFile(attachment.path));
}
});
}
@@ -4238,7 +4238,7 @@ export class ConversationModel {
const downscaledAttachment =
await downscaleOutgoingAttachment(attachment);
if (downscaledAttachment !== attachment && attachment.path) {
drop(deleteAttachmentData(attachment.path));
drop(maybeDeleteAttachmentFile(attachment.path));
}
return downscaledAttachment;
})
@@ -5156,7 +5156,7 @@ export class ConversationModel {
{
data: decrypted,
writeNewAttachmentData,
deleteAttachmentData,
deleteAttachmentData: maybeDeleteAttachmentFile,
doesAttachmentExist,
}
);
@@ -5689,7 +5689,7 @@ export class ConversationModel {
);
return getAbsoluteTempPath(tempPath);
} finally {
await deleteAttachmentData(plaintextPath);
await maybeDeleteAttachmentFile(plaintextPath);
}
}