mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
Merge pull request #3590 from eliandoran/feature/fix_broken_reference_check
Fix broken reference consistency check
This commit is contained in:
commit
2c8fb90ecb
@ -148,13 +148,20 @@ class ConsistencyChecks {
|
|||||||
AND notes.noteId IS NULL`,
|
AND notes.noteId IS NULL`,
|
||||||
({branchId, parentNoteId}) => {
|
({branchId, parentNoteId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
const branch = becca.getBranch(branchId);
|
// Delete the old branch and recreate it with root as parent.
|
||||||
branch.parentNoteId = 'root';
|
const oldBranch = becca.getBranch(branchId);
|
||||||
branch.save();
|
const noteId = oldBranch.noteId;
|
||||||
|
oldBranch.markAsDeleted("missing-parent");
|
||||||
|
|
||||||
|
const newBranch = new Branch({
|
||||||
|
parentNoteId: 'root',
|
||||||
|
noteId: noteId,
|
||||||
|
prefix: 'recovered'
|
||||||
|
}).save();
|
||||||
|
|
||||||
this.reloadNeeded = true;
|
this.reloadNeeded = true;
|
||||||
|
|
||||||
logFix(`Branch '${branchId}' was set to root parent since it was referencing missing parent note '${parentNoteId}'`);
|
logFix(`Branch '${branchId}' was was missing parent note '${parentNoteId}', so it was deleted. ${newBranch.branchId} was created in the root instead.`);
|
||||||
} else {
|
} else {
|
||||||
logError(`Branch '${branchId}' references missing parent note '${parentNoteId}'`);
|
logError(`Branch '${branchId}' references missing parent note '${parentNoteId}'`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user