mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-27 03:43:27 +01:00
Fix sql error when restoring from interrupted sync
This commit is contained in:
@@ -541,6 +541,9 @@ export const DataWriter: ServerWritableInterface = {
|
||||
enableMessageInsertTriggersAndBackfill,
|
||||
ensureMessageInsertTriggersAreEnabled,
|
||||
|
||||
disableFSync,
|
||||
enableFSyncAndCheckpoint,
|
||||
|
||||
// Server-only
|
||||
|
||||
removeKnownStickers,
|
||||
@@ -7490,9 +7493,6 @@ function disableMessageInsertTriggers(db: WritableDB): void {
|
||||
db.exec('DROP TRIGGER IF EXISTS messages_on_insert;');
|
||||
db.exec('DROP TRIGGER IF EXISTS messages_on_insert_insert_mentions;');
|
||||
})();
|
||||
|
||||
db.pragma('checkpoint_fullfsync = false');
|
||||
db.pragma('synchronous = OFF');
|
||||
}
|
||||
|
||||
const selectMentionsFromMessages = `
|
||||
@@ -7503,6 +7503,19 @@ const selectMentionsFromMessages = `
|
||||
WHERE bodyRanges.value ->> 'mentionAci' IS NOT NULL
|
||||
`;
|
||||
|
||||
function disableFSync(db: WritableDB): void {
|
||||
db.pragma('checkpoint_fullfsync = false');
|
||||
db.pragma('synchronous = OFF');
|
||||
}
|
||||
|
||||
function enableFSyncAndCheckpoint(db: WritableDB): void {
|
||||
db.pragma('checkpoint_fullfsync = true');
|
||||
db.pragma('synchronous = FULL');
|
||||
|
||||
// Finally fully commit WAL into the database
|
||||
db.pragma('wal_checkpoint(FULL)');
|
||||
}
|
||||
|
||||
function enableMessageInsertTriggersAndBackfill(db: WritableDB): void {
|
||||
const createTriggersQuery = `
|
||||
DROP TRIGGER IF EXISTS messages_on_insert;
|
||||
@@ -7532,12 +7545,6 @@ function enableMessageInsertTriggersAndBackfill(db: WritableDB): void {
|
||||
value: false,
|
||||
});
|
||||
})();
|
||||
|
||||
db.pragma('checkpoint_fullfsync = true');
|
||||
db.pragma('synchronous = FULL');
|
||||
|
||||
// Finally fully commit WAL into the database
|
||||
db.pragma('wal_checkpoint(FULL)');
|
||||
}
|
||||
|
||||
function backfillMessagesFtsTable(db: WritableDB): void {
|
||||
|
||||
Reference in New Issue
Block a user