Fix "delete and restart" after database error
This commit is contained in:
parent
9c48a95eb5
commit
455820a9cf
3 changed files with 15 additions and 1 deletions
2
main.js
2
main.js
|
@ -1318,7 +1318,7 @@ app.on('ready', async () => {
|
||||||
`Database startup error:\n\n${redactAll(sqlError.stack)}`
|
`Database startup error:\n\n${redactAll(sqlError.stack)}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await sql.sqlCall('removeDB', []);
|
await sql.removeDB();
|
||||||
removeUserConfig();
|
removeUserConfig();
|
||||||
app.relaunch();
|
app.relaunch();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ export type WorkerRequest =
|
||||||
| {
|
| {
|
||||||
readonly type: 'close';
|
readonly type: 'close';
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
readonly type: 'removeDB';
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
readonly type: 'sqlCall';
|
readonly type: 'sqlCall';
|
||||||
readonly method: string;
|
readonly method: string;
|
||||||
|
@ -117,6 +120,10 @@ export class MainSQL {
|
||||||
await this.onExit;
|
await this.onExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async removeDB(): Promise<void> {
|
||||||
|
await this.send({ type: 'removeDB' });
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
public async sqlCall(method: string, args: ReadonlyArray<any>): Promise<any> {
|
public async sqlCall(method: string, args: ReadonlyArray<any>): Promise<any> {
|
||||||
if (this.onReady) {
|
if (this.onReady) {
|
||||||
|
|
|
@ -39,6 +39,13 @@ port.on('message', async ({ seq, request }: WrappedWorkerRequest) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.type === 'removeDB') {
|
||||||
|
await db.removeDB();
|
||||||
|
|
||||||
|
respond(seq, undefined, undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (request.type === 'sqlCall') {
|
if (request.type === 'sqlCall') {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const method = (db as any)[request.method];
|
const method = (db as any)[request.method];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue