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

This commit is contained in:
zadam 2023-02-10 10:12:58 +01:00
parent ade22ea825
commit adf222b5e8

View File

@ -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;