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
fixed waitForSync
zadambcbf1b79c3aa
diff --git a/package-lock.json b/package-lock.jsonindex ca100c8b47..e600674b3d 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,6 +1,6 @@{"name": "trilium",- "version": "0.40.4",+ "version": "0.40.5","lockfileVersion": 1,"requires": true,"dependencies": {@@ -2113,9 +2113,9 @@"integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI="},"dayjs": {- "version": "1.8.21",- "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.21.tgz",- "integrity": "sha512-1kbWK0hziklUHkGgiKr7xm59KwAg/K3Tp7H/8X+f58DnNCwY3pKYjOCJpIlVs125FRBukGVZdKZojC073D0IeQ=="+ "version": "1.8.22",+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.22.tgz",+ "integrity": "sha512-N8IXfxBD62Y9cKTuuuSoOlCXRnnzaTj1vu91r855iq6FbY5cZqOZnW/95nUn6kJiR+W9PHHrLykEoQOe6fUKxQ=="},"debug": {"version": "4.1.1",@@ -7009,9 +7009,9 @@"integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="},"open": {- "version": "7.0.2",- "resolved": "https://registry.npmjs.org/open/-/open-7.0.2.tgz",- "integrity": "sha512-70E/pFTPr7nZ9nLDPNTcj3IVqnNvKuP4VsBmoKV9YGTnChe0mlS3C4qM7qKarhZ8rGaHKLfo+vBTHXDp6ZSyLQ==",+ "version": "7.0.3",+ "resolved": "https://registry.npmjs.org/open/-/open-7.0.3.tgz",+ "integrity": "sha512-sP2ru2v0P290WFfv49Ap8MF6PkzGNnGlAwHweB4WR4mr5d2d0woiCluUeJ218w7/+PmoBy9JmYgD5A4mLcWOFA==","requires": {"is-docker": "^2.0.0","is-wsl": "^2.1.1"@@ -10063,9 +10063,9 @@}},"ws": {- "version": "7.2.1",- "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz",- "integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A=="+ "version": "7.2.3",+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",+ "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ=="},"x-xss-protection": {"version": "1.3.0",diff --git a/package.json b/package.jsonindex 17d30ee8bb..b7796d9675 100644--- a/package.json+++ b/package.json@@ -27,7 +27,7 @@"commonmark": "0.29.1","cookie-parser": "1.4.4","csurf": "1.11.0",- "dayjs": "1.8.21",+ "dayjs": "1.8.22","debug": "4.1.1","ejs": "2.7.4","electron-debug": "3.0.1",@@ -53,7 +53,7 @@"mime-types": "2.1.26","multer": "1.4.2","node-abi": "2.15.0",- "open": "7.0.2",+ "open": "7.0.3","portscanner": "2.2.0","rand-token": "0.4.0","rcedit": "2.1.0",@@ -71,7 +71,7 @@"turndown": "5.0.3","turndown-plugin-gfm": "1.0.2","unescape": "1.0.1",- "ws": "7.2.1"+ "ws": "7.2.3"},"devDependencies": {"electron": "9.0.0-beta.7",diff --git a/src/routes/routes.js b/src/routes/routes.jsindex 69ffb581d4..cb580b32d6 100644--- a/src/routes/routes.js+++ b/src/routes/routes.js@@ -44,7 +44,7 @@ const auth = require('../services/auth');const cls = require('../services/cls');const sql = require('../services/sql');const protectedSessionService = require('../services/protected_session');-const syncService = require('../services/sync');+const syncTableService = require('../services/sync_table');const csurf = require('csurf');const csrfMiddleware = csurf({@@ -53,7 +53,7 @@ const csrfMiddleware = csurf({});function apiResultHandler(req, res, result) {- res.setHeader('trilium-max-sync-id', syncService.getMaxSyncId());+ res.setHeader('trilium-max-sync-id', syncTableService.getMaxSyncId());// if it's an array and first element is integer then we consider this to be [statusCode, response] formatif (Array.isArray(result) && result.length > 0 && Number.isInteger(result[0])) {diff --git a/src/services/sync_table.js b/src/services/sync_table.jsindex f552085ccc..8134849a88 100644--- a/src/services/sync_table.js+++ b/src/services/sync_table.js@@ -8,6 +8,8 @@ const dateUtils = require('./date_utils');const log = require('./log');const cls = require('./cls');+let maxSyncId = 0;+async function insertEntitySync(entityName, entityId, sourceId, isSynced) {const sync = {entityName: entityName,@@ -19,6 +21,8 @@ async function insertEntitySync(entityName, entityId, sourceId, isSynced) {sync.id = await sql.replace("sync", sync);+ maxSyncId = Math.max(maxSyncId, sync.id);+return sync;}@@ -115,5 +119,6 @@ module.exports = {addApiTokenSync: async (apiTokenId, sourceId) => await addEntitySync("api_tokens", apiTokenId, sourceId),addEntitySync,fillAllSyncRows,- addEntitySyncsForSector+ addEntitySyncsForSector,+ getMaxSyncId: () => maxSyncId};\ No newline at end of file