mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
close db after checkAllegedGristDoc (#482)
This closes a file left open during importing, not by the import itself, but by a SQLite integrity check. This was causing imports to fail on Windows (see https://github.com/gristlabs/grist-electron/issues/3)
This commit is contained in:
parent
600f699b81
commit
903c81d348
@ -136,6 +136,7 @@ export function getDatabaseUrl(options: ConnectionOptions, includeCredentials: b
|
|||||||
*/
|
*/
|
||||||
export async function checkAllegedGristDoc(docSession: OptDocSession, fname: string) {
|
export async function checkAllegedGristDoc(docSession: OptDocSession, fname: string) {
|
||||||
const db = await SQLiteDB.openDBRaw(fname, OpenMode.OPEN_READONLY);
|
const db = await SQLiteDB.openDBRaw(fname, OpenMode.OPEN_READONLY);
|
||||||
|
try {
|
||||||
const integrityCheckResults = await db.all('PRAGMA integrity_check');
|
const integrityCheckResults = await db.all('PRAGMA integrity_check');
|
||||||
if (integrityCheckResults.length !== 1 || integrityCheckResults[0].integrity_check !== 'ok') {
|
if (integrityCheckResults.length !== 1 || integrityCheckResults[0].integrity_check !== 'ok') {
|
||||||
const uuid = uuidv4();
|
const uuid = uuidv4();
|
||||||
@ -143,6 +144,9 @@ export async function checkAllegedGristDoc(docSession: OptDocSession, fname: str
|
|||||||
...getLogMetaFromDocSession(docSession)});
|
...getLogMetaFromDocSession(docSession)});
|
||||||
throw new Error(`Document failed integrity checks - is it corrupted? Event ID: ${uuid}`);
|
throw new Error(`Document failed integrity checks - is it corrupted? Event ID: ${uuid}`);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
await db.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user