Avoid foreign key error if message is deleted before saving attachments

This commit is contained in:
trevor-signal 2025-09-17 13:38:34 -04:00 committed by GitHub
commit c98a346b0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2997,10 +2997,6 @@ function saveMessage(
} satisfies Omit<MessageTypeUnhydrated, 'json'>;
if (id && !forceSave) {
if (normalizeAttachmentData) {
saveMessageAttachments(db, message);
}
const result = db
.prepare(
// UPDATE queries that set the value of a primary key column can be very slow when
@ -3019,6 +3015,10 @@ function saveMessage(
return id;
}
if (normalizeAttachmentData) {
saveMessageAttachments(db, message);
}
if (jobToInsert) {
insertJob(db, jobToInsert);
}