From b89ea9a684b0a1fe9ee916b760b39c877250ecab Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 31 Mar 2021 22:35:10 +0200 Subject: [PATCH] check for note cache branch existence, #1808 --- src/services/tree.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/tree.js b/src/services/tree.js index 46c99e66a..98d1b6205 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -1,6 +1,7 @@ "use strict"; const sql = require('./sql'); +const log = require('./log'); const repository = require('./repository'); const Branch = require('../entities/branch'); const entityChangesService = require('./entity_changes.js'); @@ -139,7 +140,12 @@ function sortNotesByTitle(parentNoteId, foldersFirst = false, reverse = false) { sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?", [position, note.branchId]); - noteCache.branches[note.branchId].notePosition = position; + if (note.branchId in noteCache.branches) { + noteCache.branches[note.branchId].notePosition = position; + } + else { + log.info(`Branch "${note.branchId}" was not found in note cache.`); + } position += 10; }