1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Cli: Fixed crash due to missing spellfix extension

This commit is contained in:
Laurent Cozic
2020-09-23 12:14:17 +01:00
parent 25ab3c323b
commit 2200be697e
3 changed files with 22 additions and 3 deletions

View File

@@ -741,6 +741,14 @@ class BaseApplication {
Setting.setValue('db.fuzzySearchEnabled', fuzzySearchEnabled ? 1 : 0); Setting.setValue('db.fuzzySearchEnabled', fuzzySearchEnabled ? 1 : 0);
} }
// Always disable on CLI because building and packaging the extension is not working
// and is too error-prone - requires gcc on the machine, or we should package the .so
// and dylib files, but it's not sure it would work everywhere if not built from
// source on the target machine.
if (Setting.value('appType') !== 'desktop') {
Setting.setValue('db.fuzzySearchEnabled', 0);
}
if (Setting.value('encryption.shouldReencrypt') < 0) { if (Setting.value('encryption.shouldReencrypt') < 0) {
// We suggest re-encryption if the user has at least one notebook // We suggest re-encryption if the user has at least one notebook
// and if encryption is enabled. This code runs only when shouldReencrypt = -1 // and if encryption is enabled. This code runs only when shouldReencrypt = -1

View File

@@ -37,7 +37,15 @@ class DatabaseDriverNode {
} }
loadExtension(path) { loadExtension(path) {
return this.db_.loadExtension(path); return new Promise((resolve, reject) => {
this.db_.loadExtension(path, (error) => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
} }
selectAll(sql, params = null) { selectAll(sql, params = null) {

View File

@@ -910,9 +910,12 @@ class JoplinDatabase extends Database {
this.logger().info('Checking for database schema update...'); this.logger().info('Checking for database schema update...');
try { try {
// Note that the only extension that can be loaded as of now is spellfix.
// If it fails here, it will fail on the fuzzySearchEnabled() check above
// too, thus disabling spellfix for the app.
await this.loadExtension(this.extensionToLoad); await this.loadExtension(this.extensionToLoad);
} catch (error) { } catch (error) {
console.info(error); this.logger().error(error);
} }
let versionRow = null; let versionRow = null;
@@ -923,7 +926,7 @@ class JoplinDatabase extends Database {
if (error.message && error.message.indexOf('no such table: version') >= 0) { if (error.message && error.message.indexOf('no such table: version') >= 0) {
// Ignore // Ignore
} else { } else {
console.info(error); this.logger().info(error);
} }
} }