Skip to content

Build your personal knowledge base with Trilium Notes

server-esm: Fix a few more import issues

Elian Doran8ac8f6c2df7f
diff --git a/src/services/sql.ts b/src/services/sql.ts
index df9742d3ba..0d92e62091 100644
--- a/src/services/sql.ts
+++ b/src/services/sql.ts
@@ -10,6 +10,9 @@ import dataDir from "./data_dir.js";
import cls from "./cls.js";
import fs from "fs-extra";
import Database from "better-sqlite3";
+import ws from "./ws.js";
+import becca_loader from "../becca/becca_loader.js";
+import entity_changes from "./entity_changes.js";
const dbConnection: DatabaseType = new Database(dataDir.DOCUMENT_PATH);
dbConnection.pragma('journal_mode = WAL');
@@ -248,7 +251,7 @@ function transactional<T>(func: (statement: Statement) => T) {
const ret = (dbConnection.transaction(func) as any).deferred();
if (!dbConnection.inTransaction) { // i.e. transaction was really committed (and not just savepoint released)
- require('./ws').sendTransactionEntityChangesToAllClients();
+ ws.sendTransactionEntityChangesToAllClients();
}
return ret;
@@ -259,11 +262,11 @@ function transactional<T>(func: (statement: Statement) => T) {
if (entityChangeIds.length > 0) {
log.info("Transaction rollback dirtied the becca, forcing reload.");
- require('../becca/becca_loader').load();
+ becca_loader.load();
}
// the maxEntityChangeId has been incremented during failed transaction, need to recalculate
- require('./entity_changes').recalculateMaxEntityChangeId();
+ entity_changes.recalculateMaxEntityChangeId();
throw e;
}
diff --git a/src/services/sync.ts b/src/services/sync.ts
index f5b6e6178e..9f6bdeb8a4 100644
--- a/src/services/sync.ts
+++ b/src/services/sync.ts
@@ -20,6 +20,7 @@ import becca from "../becca/becca.js";
import { EntityChange, EntityChangeRecord, EntityRow } from './entity_changes_interface';
import { CookieJar, ExecOpts } from './request_interface';
import setupService from "./setup.js";
+import consistency_checks from "./consistency_checks.js";
let proxyToggle = true;
@@ -281,8 +282,7 @@ async function checkContentHash(syncContext: SyncContext) {
if (failedChecks.length > 0) {
// before re-queuing sectors, make sure the entity changes are correct
- const consistencyChecks = require('./consistency_checks');
- consistencyChecks.runEntityChangesChecks();
+ consistency_checks.runEntityChangesChecks();
await syncRequest(syncContext, 'POST', `/api/sync/check-entity-changes`);
}
diff --git a/src/share/routes.ts b/src/share/routes.ts
index 51a0c2ff54..b491b5a7e7 100644
--- a/src/share/routes.ts
+++ b/src/share/routes.ts
@@ -250,8 +250,6 @@ function register(router: Router) {
addNoIndexHeader(note, res);
- const utils = require('../services/utils');
-
const filename = utils.formatDownloadTitle(note.title, note.type, note.mime);
res.setHeader('Content-Disposition', utils.getContentDisposition(filename));