From bfa2b5fa62d260b157c261e3fcf859f23c3c039e Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 21 Oct 2018 21:37:34 +0200 Subject: [PATCH] add a check for root parent --- src/services/consistency_checks.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 44abe110d..3671bf970 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -28,10 +28,7 @@ async function checkTreeCycles(errorList) { const childNoteId = row.noteId; const parentNoteId = row.parentNoteId; - if (!childToParents[childNoteId]) { - childToParents[childNoteId] = []; - } - + childToParents[childNoteId] = childToParents[childNoteId] || []; childToParents[childNoteId].push(parentNoteId); } @@ -58,6 +55,10 @@ async function checkTreeCycles(errorList) { for (const noteId of noteIds) { checkTreeCycle(noteId, [], errorList); } + + if (childToParents['root'].length !== 1 || childToParents['root'][0] !== 'none') { + errorList.push('Incorrect root parent: ' + JSON.stringify(childToParents['root'])); + } } async function runSyncRowChecks(table, key, errorList) {