Merge branch 'master' into next53

This commit is contained in:
zadam 2022-05-31 22:21:29 +02:00
commit 88586b0f25
5 changed files with 39 additions and 23 deletions

View File

@ -134,8 +134,6 @@ const TPL = `
Delete note</a> Delete note</a>
<a class="dropdown-item" href="#" data-action-add="deleteNoteRevisions"> <a class="dropdown-item" href="#" data-action-add="deleteNoteRevisions">
Delete note revisions</a> Delete note revisions</a>
<a class="dropdown-item" href="#" data-action-add="moveNote">
Delete note revisions</a>
<a class="dropdown-item" href="#" data-action-add="deleteLabel"> <a class="dropdown-item" href="#" data-action-add="deleteLabel">
Delete label</a> Delete label</a>
<a class="dropdown-item" href="#" data-action-add="deleteRelation"> <a class="dropdown-item" href="#" data-action-add="deleteRelation">

View File

@ -2,7 +2,7 @@ import libraryLoader from "../../services/library_loader.js";
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import utils from '../../services/utils.js'; import utils from '../../services/utils.js';
import froca from "../../services/froca.js"; import froca from "../../services/froca.js";
import debounce from "../../../../../libraries/lodash.debounce.js"; import debounce from "../../../libraries/lodash.debounce.js";
const {sleep} = utils; const {sleep} = utils;

View File

@ -426,6 +426,15 @@ function BackendScriptApi(currentNote, apiParams) {
* @return {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version * @return {{syncVersion, appVersion, buildRevision, dbVersion, dataDirectory, buildDate}|*} - object representing basic info about running Trilium version
*/ */
this.getAppInfo = () => appInfo 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; module.exports = BackendScriptApi;

View File

@ -367,26 +367,30 @@ class ConsistencyChecks {
} }
}); });
this.findAndFixIssues(` if (sqlInit.getDbSize() < 500000) {
SELECT notes.noteId, notes.type, notes.mime // querying for "content IS NULL" is expensive since content is not indexed. See e.g. https://github.com/zadam/trilium/issues/2887
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);
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`); this.reloadNeeded = true;
} else {
logError(`Note ${noteId} content is null even though it is not deleted`); 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(` this.findAndFixIssues(`
SELECT note_revisions.noteRevisionId SELECT note_revisions.noteRevisionId

View File

@ -178,7 +178,11 @@ dbReady.then(() => {
setInterval(() => optimize(), 10 * 60 * 60 * 1000); 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 = { module.exports = {
dbReady, dbReady,
@ -186,5 +190,6 @@ module.exports = {
isDbInitialized, isDbInitialized,
createInitialDatabase, createInitialDatabase,
createDatabaseForSync, createDatabaseForSync,
setDbAsInitialized setDbAsInitialized,
getDbSize
}; };