Enable backfilling of attachments without message_attachment rows

This commit is contained in:
trevor-signal 2025-08-26 23:20:14 -04:00 committed by GitHub
commit 37ec000831
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 109 additions and 8 deletions

View file

@ -705,6 +705,8 @@ export const DataWriter: ServerWritableInterface = {
disableFSync,
enableFSyncAndCheckpoint,
_testOnlyRemoveMessageAttachments,
// Server-only
removeKnownStickers,
@ -2720,6 +2722,17 @@ function saveMessageAttachment({
).run(values);
}
function _testOnlyRemoveMessageAttachments(
db: WritableDB,
timestamp: number
): void {
const [query, params] = sql`
DELETE FROM message_attachments
WHERE sentAt = ${timestamp};`;
db.prepare(query).run(params);
}
function saveMessage(
db: WritableDB,
message: ReadonlyDeep<MessageType>,