Fix "delete and restart" after database error

This commit is contained in:
Fedor Indutny 2021-07-09 17:43:36 -07:00 committed by GitHub
parent 9c48a95eb5
commit 455820a9cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -1318,7 +1318,7 @@ app.on('ready', async () => {
`Database startup error:\n\n${redactAll(sqlError.stack)}`
);
} else {
await sql.sqlCall('removeDB', []);
await sql.removeDB();
removeUserConfig();
app.relaunch();
}

View File

@ -22,6 +22,9 @@ export type WorkerRequest =
| {
readonly type: 'close';
}
| {
readonly type: 'removeDB';
}
| {
readonly type: 'sqlCall';
readonly method: string;
@ -117,6 +120,10 @@ export class MainSQL {
await this.onExit;
}
public async removeDB(): Promise<void> {
await this.send({ type: 'removeDB' });
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async sqlCall(method: string, args: ReadonlyArray<any>): Promise<any> {
if (this.onReady) {

View File

@ -39,6 +39,13 @@ port.on('message', async ({ seq, request }: WrappedWorkerRequest) => {
return;
}
if (request.type === 'removeDB') {
await db.removeDB();
respond(seq, undefined, undefined);
return;
}
if (request.type === 'sqlCall') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const method = (db as any)[request.method];