Run WAL checkpoint on exit
This commit is contained in:
parent
763c35e546
commit
d222376b8f
|
@ -32,6 +32,7 @@ import {
|
|||
|
||||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import { GroupV2MemberType } from '../model-types.d';
|
||||
import * as Errors from '../types/errors';
|
||||
import { ReactionType } from '../types/Reactions';
|
||||
import { StoredJob } from '../jobs/types';
|
||||
import { assert } from '../util/assert';
|
||||
|
@ -2286,9 +2287,17 @@ async function close(): Promise<void> {
|
|||
const dbRef = globalInstance;
|
||||
globalInstance = undefined;
|
||||
|
||||
// SQLLite documentation suggests that we run `PRAGMA optimize` right before
|
||||
// closing the database connection.
|
||||
dbRef.pragma('optimize');
|
||||
if (!isRenderer()) {
|
||||
// SQLLite documentation suggests that we run `PRAGMA optimize` right
|
||||
// before closing the database connection.
|
||||
dbRef.pragma('optimize');
|
||||
|
||||
try {
|
||||
dbRef.pragma('wal_checkpoint(TRUNCATE)');
|
||||
} catch (error) {
|
||||
console.error('Failed to truncate WAL log', Errors.toLogFormat(error));
|
||||
}
|
||||
}
|
||||
|
||||
dbRef.close();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue