Skip to content

Build your personal knowledge base with Trilium Notes

fix consistency check to re-parent note from search parent to root

zadamadf222b5e851
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index 4cc8e6cbb1..4ba2cae081 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;