1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Cli: Fix last change sometimes lost when not in TUI mode (#13090)

This commit is contained in:
Henry Heino
2025-09-08 04:03:13 -07:00
committed by GitHub
parent 88f687ba6a
commit f6b3f9860c
4 changed files with 16 additions and 2 deletions

View File

@@ -432,6 +432,7 @@ class Application extends BaseApplication {
}
await Setting.saveAll();
await this.database_.close();
// Need to call exit() explicitly, otherwise Node wait for any timeout to complete
// https://stackoverflow.com/questions/18050095

View File

@@ -90,8 +90,7 @@ export default class BaseApplication {
private eventEmitter_: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
private scheduleAutoAddResourcesIID_: any = null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
private database_: any = null;
protected database_: JoplinDatabase = null;
private profileConfig_: ProfileConfig = null;
protected showStackTraces_ = false;

View File

@@ -16,6 +16,12 @@ class DatabaseDriverNode {
});
}
close() {
return new Promise(resolve => {
this.db_.close(() => resolve());
});
}
sqliteErrorToJsError(error, sql = null, params = null) {
const msg = [error.toString()];
if (sql) msg.push(sql);

View File

@@ -65,6 +65,14 @@ export default class Database {
this.logger().info('Database was open successfully');
}
public async close() {
try {
await this.driver().close?.();
} catch (error) {
this.logger().warn('Failed to close database', error);
}
}
public escapeField(field: string) {
if (field === '*') return '*';
const p = field.split('.');