@ -136,12 +136,16 @@ 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 ) ;
const integrityCheckResults = await db . all ( 'PRAGMA integrity_check' ) ;
try {
if ( integrityCheckResults . length !== 1 || integrityCheckResults [ 0 ] . integrity_check !== 'ok' ) {
const integrityCheckResults = await db . all ( 'PRAGMA integrity_check' ) ;
const uuid = uuidv4 ( ) ;
if ( integrityCheckResults . length !== 1 || integrityCheckResults [ 0 ] . integrity_check !== 'ok' ) {
log . info ( 'Integrity check failure on import' , { uuid , integrityCheckResults ,
const uuid = uuidv4 ( ) ;
. . . getLogMetaFromDocSession ( docSession ) } ) ;
log . info ( 'Integrity check failure on import' , { uuid , integrityCheckResults ,
throw new Error ( ` Document failed integrity checks - is it corrupted? Event ID: ${ uuid } ` ) ;
. . . getLogMetaFromDocSession ( docSession ) } ) ;
throw new Error ( ` Document failed integrity checks - is it corrupted? Event ID: ${ uuid } ` ) ;
}
} finally {
await db . close ( ) ;
}
}
}
}