From deb67d627540a15c16365d13d245d136e3e9ab3a Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 8 Mar 2020 21:05:52 +0100 Subject: [PATCH 1/3] release 0.40.5 --- package.json | 2 +- src/services/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b3029e87..98e0488a5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.40.4", + "version": "0.40.5", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/services/build.js b/src/services/build.js index 96eeb5fd3..7ed5b250e 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2020-02-24T22:59:22+01:00", buildRevision: "fb55cdaea6b1367129e11118b8b6fd2eadebad5f" }; +module.exports = { buildDate:"2020-03-08T21:05:52+01:00", buildRevision: "e4039ea5e1c6ac87e0947bc77b6bdcbb29a23092" }; From 719f10981e39f59837ba66494e47de914fe2fe11 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 8 Mar 2020 22:00:12 +0100 Subject: [PATCH 2/3] fix sync --- src/services/sync_update.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/sync_update.js b/src/services/sync_update.js index 4415a62df..10b8a5112 100644 --- a/src/services/sync_update.js +++ b/src/services/sync_update.js @@ -4,6 +4,11 @@ const syncTableService = require('./sync_table'); const eventService = require('./events'); async function updateEntity(sync, entity, sourceId) { + // can be undefined for options with isSynced=false + if (!entity) { + return; + } + const {entityName} = sync; if (entityName === 'notes') { From 73bf2dcb0261e9a8944aca59bf7439a3665cb4f4 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 9 Mar 2020 20:56:43 +0100 Subject: [PATCH 3/3] added isSynced to sync table to allow forward compatibility with 0.41 --- db/migrations/0158__add_isSynced_to_sync.sql | 22 ++++++++++++++++++++ src/routes/api/app_info.js | 4 ++-- src/services/app_info.js | 2 +- src/services/consistency_checks.js | 2 +- src/services/sync_table.js | 3 ++- src/services/sync_update.js | 5 ----- 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 db/migrations/0158__add_isSynced_to_sync.sql diff --git a/db/migrations/0158__add_isSynced_to_sync.sql b/db/migrations/0158__add_isSynced_to_sync.sql new file mode 100644 index 000000000..a2d978bc1 --- /dev/null +++ b/db/migrations/0158__add_isSynced_to_sync.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS "sync_mig" ( + `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + `entityName` TEXT NOT NULL, + `entityId` TEXT NOT NULL, + `sourceId` TEXT NOT NULL, + `isSynced` INTEGER default 0 not null, + `utcSyncDate` TEXT NOT NULL); + +INSERT INTO sync_mig (entityName, entityId, sourceId, isSynced, utcSyncDate) +SELECT entityName, entityId, sourceId, 1, utcSyncDate FROM sync; + +DROP TABLE sync; + +ALTER TABLE sync_mig RENAME TO sync; + +CREATE UNIQUE INDEX `IDX_sync_entityName_entityId` ON `sync` ( + `entityName`, + `entityId` + ); +CREATE INDEX `IDX_sync_utcSyncDate` ON `sync` ( + `utcSyncDate` + ); \ No newline at end of file diff --git a/src/routes/api/app_info.js b/src/routes/api/app_info.js index b574d14a1..12f5a46c7 100644 --- a/src/routes/api/app_info.js +++ b/src/routes/api/app_info.js @@ -1,9 +1,9 @@ "use strict"; -const app_info = require('../../services/app_info'); +const appInfo = require('../../services/app_info'); async function getAppInfo() { - return app_info; + return appInfo; } module.exports = { diff --git a/src/services/app_info.js b/src/services/app_info.js index 0c30da676..0df3b0b74 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -4,7 +4,7 @@ const build = require('./build'); const packageJson = require('../../package'); const {TRILIUM_DATA_DIR} = require('./data_dir'); -const APP_DB_VERSION = 157; +const APP_DB_VERSION = 158; const SYNC_VERSION = 14; const CLIPPER_PROTOCOL_VERSION = "1.0"; diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 871706a11..4c0cfee7c 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -546,7 +546,7 @@ class ConsistencyChecks { ${entityName} LEFT JOIN sync ON sync.entityName = '${entityName}' AND entityId = ${key} WHERE - sync.id IS NULL AND ` + (entityName === 'options' ? 'isSynced = 1' : '1'), + sync.id IS NULL AND ` + (entityName === 'options' ? 'options.isSynced = 1' : '1'), async ({entityId}) => { if (this.autoFix) { await syncTableService.addEntitySync(entityName, entityId); diff --git a/src/services/sync_table.js b/src/services/sync_table.js index 75906e7d4..c96cf2ba0 100644 --- a/src/services/sync_table.js +++ b/src/services/sync_table.js @@ -11,7 +11,8 @@ async function insertEntitySync(entityName, entityId, sourceId) { entityName: entityName, entityId: entityId, utcSyncDate: dateUtils.utcNowDateTime(), - sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId() + sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(), + isSynced: 1 }; sync.id = await sql.replace("sync", sync); diff --git a/src/services/sync_update.js b/src/services/sync_update.js index 10b8a5112..4415a62df 100644 --- a/src/services/sync_update.js +++ b/src/services/sync_update.js @@ -4,11 +4,6 @@ const syncTableService = require('./sync_table'); const eventService = require('./events'); async function updateEntity(sync, entity, sourceId) { - // can be undefined for options with isSynced=false - if (!entity) { - return; - } - const {entityName} = sync; if (entityName === 'notes') {