@ -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 ( ) ;
}
}
}
/ * *
/ * *