Separate calls in sql channel

This commit is contained in:
Fedor Indutny 2024-08-12 12:54:24 -07:00 committed by GitHub
parent 85b130a12d
commit 9a98ae0a4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 90 additions and 45 deletions

View file

@ -9,6 +9,7 @@ import { app } from 'electron';
import { strictAssert } from '../util/assert';
import { explodePromise } from '../util/explodePromise';
import type { LoggerType } from '../types/Logging';
import * as Errors from '../types/errors';
import { SqliteErrorKind } from './errors';
import type {
ServerReadableDirectInterface,
@ -200,6 +201,16 @@ export class MainSQL {
}
public async close(): Promise<void> {
if (this.onReady) {
try {
await this.onReady;
} catch (err) {
this.logger?.error(`MainSQL close, failed: ${Errors.toLogFormat(err)}`);
// Init failed
return;
}
}
if (!this.isReady) {
throw new Error('Not initialized');
}
@ -256,11 +267,6 @@ export class MainSQL {
await promise;
}
// Special case since we need to broadcast this to every pool entry.
if (method === 'removeDB') {
return (await this.removeDB()) as Result;
}
const primary = this.pool[0];
const { result, duration } = await this.send<SqlCallResult>(primary, {