diff --git a/src/public/app/widgets/ribbon_widgets/search_definition.js b/src/public/app/widgets/ribbon_widgets/search_definition.js
index c6872877d..824bd4669 100644
--- a/src/public/app/widgets/ribbon_widgets/search_definition.js
+++ b/src/public/app/widgets/ribbon_widgets/search_definition.js
@@ -134,8 +134,6 @@ const TPL = `
Delete note
Delete note revisions
-
- Delete note revisions
Delete label
diff --git a/src/public/app/widgets/type_widgets/canvas.js b/src/public/app/widgets/type_widgets/canvas.js
index 0512e3ede..98acf2fa7 100644
--- a/src/public/app/widgets/type_widgets/canvas.js
+++ b/src/public/app/widgets/type_widgets/canvas.js
@@ -2,7 +2,7 @@ import libraryLoader from "../../services/library_loader.js";
import TypeWidget from "./type_widget.js";
import utils from '../../services/utils.js';
import froca from "../../services/froca.js";
-import debounce from "../../../../../libraries/lodash.debounce.js";
+import debounce from "../../../libraries/lodash.debounce.js";
const {sleep} = utils;
diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js
index dadc40c6a..c457bbaf6 100644
--- a/src/services/backend_script_api.js
+++ b/src/services/backend_script_api.js
@@ -426,6 +426,15 @@ function BackendScriptApi(currentNote, apiParams) {
* @return {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version
*/
this.getAppInfo = () => appInfo
+
+ /**
+ * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
+ *
+ * @type {{becca: Becca}}
+ */
+ this.__private = {
+ becca
+ }
}
module.exports = BackendScriptApi;
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index dbf4b4478..0731989c1 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -367,26 +367,30 @@ class ConsistencyChecks {
}
});
- this.findAndFixIssues(`
- SELECT notes.noteId, notes.type, notes.mime
- FROM notes
- JOIN note_contents USING (noteId)
- WHERE isDeleted = 0
- AND isProtected = 0
- AND content IS NULL`,
- ({noteId, type, mime}) => {
- if (this.autoFix) {
- const note = becca.getNote(noteId);
- const blankContent = getBlankContent(false, type, mime);
- note.setContent(blankContent);
+ if (sqlInit.getDbSize() < 500000) {
+ // querying for "content IS NULL" is expensive since content is not indexed. See e.g. https://github.com/zadam/trilium/issues/2887
- this.reloadNeeded = true;
+ this.findAndFixIssues(`
+ SELECT notes.noteId, notes.type, notes.mime
+ FROM notes
+ JOIN note_contents USING (noteId)
+ WHERE isDeleted = 0
+ AND isProtected = 0
+ AND content IS NULL`,
+ ({noteId, type, mime}) => {
+ if (this.autoFix) {
+ const note = becca.getNote(noteId);
+ const blankContent = getBlankContent(false, type, mime);
+ note.setContent(blankContent);
- logFix(`Note ${noteId} content was set to "${blankContent}" since it was null even though it is not deleted`);
- } else {
- logError(`Note ${noteId} content is null even though it is not deleted`);
- }
- });
+ this.reloadNeeded = true;
+
+ logFix(`Note ${noteId} content was set to "${blankContent}" since it was null even though it is not deleted`);
+ } else {
+ logError(`Note ${noteId} content is null even though it is not deleted`);
+ }
+ });
+ }
this.findAndFixIssues(`
SELECT note_revisions.noteRevisionId
diff --git a/src/services/sql_init.js b/src/services/sql_init.js
index 013f736b7..66bc98fe9 100644
--- a/src/services/sql_init.js
+++ b/src/services/sql_init.js
@@ -178,7 +178,11 @@ dbReady.then(() => {
setInterval(() => optimize(), 10 * 60 * 60 * 1000);
});
-log.info("DB size: " + sql.getValue("SELECT page_count * page_size / 1000 as size FROM pragma_page_count(), pragma_page_size()") + " KB");
+function getDbSize() {
+ return sql.getValue("SELECT page_count * page_size / 1000 as size FROM pragma_page_count(), pragma_page_size()");
+}
+
+log.info(`DB size: ${getDbSize()} KB`);
module.exports = {
dbReady,
@@ -186,5 +190,6 @@ module.exports = {
isDbInitialized,
createInitialDatabase,
createDatabaseForSync,
- setDbAsInitialized
+ setDbAsInitialized,
+ getDbSize
};