From b8fe9a41dba4dfa1ca011b59683aaf7966c2cab3 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 27 Dec 2021 13:37:51 +0100 Subject: [PATCH] fix consistency checks --- src/services/consistency_checks.js | 2 +- src/services/import/zip.js | 32 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 76debe2db..6198d9bec 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -259,7 +259,7 @@ class ConsistencyChecks { WHERE noteId = ? and parentNoteId = ? and isDeleted = 0 - ORDER BY utcDateCreated`, [noteId, parentNoteId]); + ORDER BY utcDateModified`, [noteId, parentNoteId]); const branches = branchIds.map(branchId => becca.getBranch(branchId)); diff --git a/src/services/import/zip.js b/src/services/import/zip.js index 91a805222..f7706b8eb 100644 --- a/src/services/import/zip.js +++ b/src/services/import/zip.js @@ -240,13 +240,15 @@ async function importZip(taskContext, fileBuffer, importRootNote) { } if (noteMeta && noteMeta.isClone) { - new Branch({ - noteId, - parentNoteId, - isExpanded: noteMeta.isExpanded, - prefix: noteMeta.prefix, - notePosition: noteMeta.notePosition - }).save(); + if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { + new Branch({ + noteId, + parentNoteId, + isExpanded: noteMeta.isExpanded, + prefix: noteMeta.prefix, + notePosition: noteMeta.notePosition + }).save(); + } return; } @@ -366,13 +368,15 @@ async function importZip(taskContext, fileBuffer, importRootNote) { note.setContent(content); - new Branch({ - noteId, - parentNoteId, - isExpanded: noteMeta.isExpanded, - prefix: noteMeta.prefix, - notePosition: noteMeta.notePosition - }).save(); + if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { + new Branch({ + noteId, + parentNoteId, + isExpanded: noteMeta.isExpanded, + prefix: noteMeta.prefix, + notePosition: noteMeta.notePosition + }).save(); + } } else { ({note} = noteService.createNewNote({