Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
disable scanning for links while migration is running #4535
zadam807941e6a507
diff --git a/src/services/cls.js b/src/services/cls.jsindex 0bfde4436f..8e2c2870c0 100644--- a/src/services/cls.js+++ b/src/services/cls.js@@ -48,6 +48,14 @@ function isEntityEventsDisabled() {return !!namespace.get('disableEntityEvents');}+function setMigrationRunning(running) {+ namespace.set('migrationRunning', !!running);+}++function isMigrationRunning() {+ return !!namespace.get('migrationRunning');+}+function disableSlowQueryLogging(disable) {namespace.set('disableSlowQueryLogging', disable);}@@ -102,5 +110,7 @@ module.exports = {putEntityChange,ignoreEntityChangeIds,disableSlowQueryLogging,- isSlowQueryLoggingDisabled+ isSlowQueryLoggingDisabled,+ setMigrationRunning,+ isMigrationRunning};diff --git a/src/services/migration.js b/src/services/migration.jsindex 58b910d7ba..e5ca3dc6c0 100644--- a/src/services/migration.js+++ b/src/services/migration.js@@ -5,6 +5,7 @@ const log = require('./log');const utils = require('./utils');const resourceDir = require('./resource_dir');const appInfo = require('./app_info');+const cls = require('./cls.js');async function migrate() {const currentDbVersion = getDbVersion();@@ -51,6 +52,9 @@ async function migrate() {// all migrations are executed in one transaction - upgrade either succeeds, or the user can stay at the old version// otherwise if half of the migrations succeed, user can't use any version - DB is too "new" for the old app,// and too old for the new app version.++ cls.setMigrationRunning(true);+sql.transactional(() => {for (const mig of migrations) {try {diff --git a/src/services/notes.js b/src/services/notes.jsindex 04f457f814..93b8313be1 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -895,6 +895,11 @@ function scanForLinks(note, content) {* Things which have to be executed after updating content, but asynchronously (separate transaction)*/async function asyncPostProcessContent(note, content) {+ if (cls.isMigrationRunning()) {+ // this is rarely needed for migrations, but can cause trouble by e.g. triggering downloads+ return;+ }+if (note.hasStringContent() && !utils.isString(content)) {content = content.toString();}