Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 8ac8f6c

Browse files
committed
server-esm: Fix a few more import issues
1 parent ad93fe4 commit 8ac8f6c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/services/sql.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import dataDir from "./data_dir.js";
1010
import cls from "./cls.js";
1111
import fs from "fs-extra";
1212
import Database from "better-sqlite3";
13+
import ws from "./ws.js";
14+
import becca_loader from "../becca/becca_loader.js";
15+
import entity_changes from "./entity_changes.js";
1316

1417
const dbConnection: DatabaseType = new Database(dataDir.DOCUMENT_PATH);
1518
dbConnection.pragma('journal_mode = WAL');
@@ -248,7 +251,7 @@ function transactional<T>(func: (statement: Statement) => T) {
248251
const ret = (dbConnection.transaction(func) as any).deferred();
249252

250253
if (!dbConnection.inTransaction) { // i.e. transaction was really committed (and not just savepoint released)
251-
require('./ws').sendTransactionEntityChangesToAllClients();
254+
ws.sendTransactionEntityChangesToAllClients();
252255
}
253256

254257
return ret;
@@ -259,11 +262,11 @@ function transactional<T>(func: (statement: Statement) => T) {
259262
if (entityChangeIds.length > 0) {
260263
log.info("Transaction rollback dirtied the becca, forcing reload.");
261264

262-
require('../becca/becca_loader').load();
265+
becca_loader.load();
263266
}
264267

265268
// the maxEntityChangeId has been incremented during failed transaction, need to recalculate
266-
require('./entity_changes').recalculateMaxEntityChangeId();
269+
entity_changes.recalculateMaxEntityChangeId();
267270

268271
throw e;
269272
}

src/services/sync.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import becca from "../becca/becca.js";
2020
import { EntityChange, EntityChangeRecord, EntityRow } from './entity_changes_interface';
2121
import { CookieJar, ExecOpts } from './request_interface';
2222
import setupService from "./setup.js";
23+
import consistency_checks from "./consistency_checks.js";
2324

2425
let proxyToggle = true;
2526

@@ -281,8 +282,7 @@ async function checkContentHash(syncContext: SyncContext) {
281282

282283
if (failedChecks.length > 0) {
283284
// before re-queuing sectors, make sure the entity changes are correct
284-
const consistencyChecks = require('./consistency_checks');
285-
consistencyChecks.runEntityChangesChecks();
285+
consistency_checks.runEntityChangesChecks();
286286

287287
await syncRequest(syncContext, 'POST', `/api/sync/check-entity-changes`);
288288
}

src/share/routes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ function register(router: Router) {
250250

251251
addNoIndexHeader(note, res);
252252

253-
const utils = require('../services/utils');
254-
255253
const filename = utils.formatDownloadTitle(note.title, note.type, note.mime);
256254

257255
res.setHeader('Content-Disposition', utils.getContentDisposition(filename));

0 commit comments

Comments
 (0)