From adf222b5e851c6978cf7a3e0a77f518bbd46a52d Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 10 Feb 2023 10:12:58 +0100 Subject: [PATCH] fix consistency check to re-parent note from search parent to root --- src/services/consistency_checks.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 4cc8e6cbb..4ba2cae08 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -443,10 +443,17 @@ class ConsistencyChecks { const branches = branchIds.map(branchId => becca.getBranch(branchId)); for (const branch of branches) { - branch.parentNoteId = 'root'; - branch.save(); + // delete the old wrong branch + branch.markAsDeleted("parent-is-search"); - logFix(`Child branch '${branch.branchId}' has been moved to root since it was a child of a search note '${parentNoteId}'`) + // create a replacement branch in root parent + new Branch({ + parentNoteId: 'root', + noteId: branch.noteId, + prefix: 'recovered' + }).save(); + + logFix(`Note '${branch.noteId}' has been moved to root since it was a child of a search note '${parentNoteId}'`) } this.reloadNeeded = true;