Optimize database and run quick check

This commit is contained in:
Fedor Indutny 2021-04-06 10:29:22 -07:00 committed by Josh Perez
parent b9248e04ed
commit 1fc7769f9f
2 changed files with 15 additions and 2 deletions

View file

@ -313,7 +313,7 @@ function getSQLCipherIntegrityCheck(db: Database): Array<string> | undefined {
}
function getSQLIntegrityCheck(db: Database): string | undefined {
const checkResult = db.pragma('integrity_check', { simple: true });
const checkResult = db.pragma('quick_check', { simple: true });
if (checkResult !== 'ok') {
return checkResult;
}
@ -1618,6 +1618,11 @@ 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');
dbRef.close();
}