Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Merge branch 'stable'
zadam7539e6a616e7
diff --cc src/services/consistency_checks.jsindex 3ca90fe9e3,5d0a286dd1..a6bdf0fd9c--- a/src/services/consistency_checks.js+++ b/src/services/consistency_checks.js@@@ -260,28 -194,18 +260,28 @@@ async function findExistencyIssues()branches.noteIdHAVINGCOUNT(*) > 1`,- async ({noteId, parentNoteId}) => {- const branches = await repository.getEntities(`SELECT * FROM branches WHERE noteId = ? and parentNoteId = ? and isDeleted = 0`, [noteId, parentNoteId]);-- // it's not necessarily "original" branch, it's just the only one which will survive- const origBranch = branches[0];-- // delete all but the first branch- for (const branch of branches.slice(1)) {- branch.isDeleted = true;- await branch.save();-- logFix(`Removing branch ${branch.branchId} since it's parent-child duplicate of branch ${origBranch.branchId}`);+ async ({noteId, parentNoteId}, autoFix) => {+ if (autoFix) {+ const branches = await repository.getEntities(+ `SELECT *+ FROM branches+ WHERE noteId = ?+ and parentNoteId = ?- and isDeleted = 1`, [noteId, parentNoteId]);++ and isDeleted = 0`, [noteId, parentNoteId]);++ // it's not necessarily "original" branch, it's just the only one which will survive+ const origBranch = branches[0];++ // delete all but the first branch+ for (const branch of branches.slice(1)) {+ branch.isDeleted = true;+ await branch.save();++ logFix(`Removing branch ${branch.branchId} since it's parent-child duplicate of branch ${origBranch.branchId}`);+ }+ }+ else {+ logError(`Duplicate branches for note ${noteId} and parent ${parentNoteId}`);}});}