From 9eff08144c27e6faa0e65088e3f3cf666da33e13 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 16 Jan 2023 08:06:19 +0100 Subject: [PATCH] extra check that hidden tree is not created until migration is completed --- src/services/hidden_subtree.js | 8 ++++++++ src/services/migration.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js index b6be8d619..b97baf4a8 100644 --- a/src/services/hidden_subtree.js +++ b/src/services/hidden_subtree.js @@ -1,6 +1,8 @@ const becca = require("../becca/becca"); const noteService = require("./notes"); const Attribute = require("../becca/entities/attribute.js"); +const log = require("./log"); +const migrationService = require("./migration"); const LBTPL_ROOT = "_lbTplRoot"; const LBTPL_BASE = "_lbTplBase"; @@ -231,6 +233,12 @@ const HIDDEN_SUBTREE_DEFINITION = { }; function checkHiddenSubtree() { + if (!migrationService.isDbUpToDate()) { + // on-delete hook might get triggered during some future migration and cause havoc + log.info("Will not check hidden subtree until migration is finished."); + return; + } + checkHiddenSubtreeRecursively('root', HIDDEN_SUBTREE_DEFINITION); } diff --git a/src/services/migration.js b/src/services/migration.js index 1bda273e4..7bda5bc36 100644 --- a/src/services/migration.js +++ b/src/services/migration.js @@ -119,5 +119,6 @@ async function migrateIfNecessary() { } module.exports = { - migrateIfNecessary + migrateIfNecessary, + isDbUpToDate };