extra check that hidden tree is not created until migration is completed

This commit is contained in:
zadam 2023-01-16 08:06:19 +01:00
parent 4ba72bc8d3
commit 9eff08144c
2 changed files with 10 additions and 1 deletions

View file

@ -1,6 +1,8 @@
const becca = require("../becca/becca"); const becca = require("../becca/becca");
const noteService = require("./notes"); const noteService = require("./notes");
const Attribute = require("../becca/entities/attribute.js"); const Attribute = require("../becca/entities/attribute.js");
const log = require("./log");
const migrationService = require("./migration");
const LBTPL_ROOT = "_lbTplRoot"; const LBTPL_ROOT = "_lbTplRoot";
const LBTPL_BASE = "_lbTplBase"; const LBTPL_BASE = "_lbTplBase";
@ -231,6 +233,12 @@ const HIDDEN_SUBTREE_DEFINITION = {
}; };
function checkHiddenSubtree() { 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); checkHiddenSubtreeRecursively('root', HIDDEN_SUBTREE_DEFINITION);
} }

View file

@ -119,5 +119,6 @@ async function migrateIfNecessary() {
} }
module.exports = { module.exports = {
migrateIfNecessary migrateIfNecessary,
isDbUpToDate
}; };