From d67246699ad9db2a3eef40797e09210b1994cb97 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 10 Jun 2018 15:55:29 -0400 Subject: [PATCH] Introduced separate sync version (previously DB version was used to check sync compatibility), closes #120 --- src/public/javascripts/dialogs/options.js | 2 ++ src/routes/api/login.js | 6 +++--- src/services/app_info.js | 2 ++ src/services/sync.js | 2 +- src/views/index.ejs | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/public/javascripts/dialogs/options.js b/src/public/javascripts/dialogs/options.js index acddb65a7..7a1020e81 100644 --- a/src/public/javascripts/dialogs/options.js +++ b/src/public/javascripts/dialogs/options.js @@ -173,6 +173,7 @@ addTabHandler((function () { addTabHandler((async function () { const $appVersion = $("#app-version"); const $dbVersion = $("#db-version"); + const $syncVersion = $("#sync-version"); const $buildDate = $("#build-date"); const $buildRevision = $("#build-revision"); @@ -180,6 +181,7 @@ addTabHandler((async function () { $appVersion.html(appInfo.appVersion); $dbVersion.html(appInfo.dbVersion); + $syncVersion.html(appInfo.syncVersion); $buildDate.html(appInfo.buildDate); $buildRevision.html(appInfo.buildRevision); $buildRevision.attr('href', 'https://github.com/zadam/trilium/commit/' + appInfo.buildRevision); diff --git a/src/routes/api/login.js b/src/routes/api/login.js index 7ecb4ac18..0c7f11634 100644 --- a/src/routes/api/login.js +++ b/src/routes/api/login.js @@ -21,10 +21,10 @@ async function loginSync(req) { return [400, { message: 'Auth request time is out of sync' }]; } - const dbVersion = req.body.dbVersion; + const syncVersion = req.body.syncVersion; - if (dbVersion !== appInfo.dbVersion) { - return [400, { message: 'Non-matching db versions, local is version ' + appInfo.dbVersion }]; + if (syncVersion !== appInfo.syncVersion) { + return [400, { message: 'Non-matching sync versions, local is version ' + appInfo.syncVersion }]; } const documentSecret = await options.getOption('documentSecret'); diff --git a/src/services/app_info.js b/src/services/app_info.js index 5a63ee9d3..ba7e24ecf 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -4,10 +4,12 @@ const build = require('./build'); const packageJson = require('../../package'); const APP_DB_VERSION = 99; +const SYNC_VERSION = 1; module.exports = { appVersion: packageJson.version, dbVersion: APP_DB_VERSION, + syncVersion: SYNC_VERSION, buildDate: build.buildDate, buildRevision: build.buildRevision }; \ No newline at end of file diff --git a/src/services/sync.js b/src/services/sync.js index 46def89eb..5a7c47e54 100644 --- a/src/services/sync.js +++ b/src/services/sync.js @@ -69,7 +69,7 @@ async function login() { const resp = await syncRequest(syncContext, 'POST', '/api/login/sync', { timestamp: timestamp, - dbVersion: appInfo.dbVersion, + syncVersion: appInfo.syncVersion, hash: hash }); diff --git a/src/views/index.ejs b/src/views/index.ejs index ff0f83131..443707f7a 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -447,12 +447,14 @@ App version: - DB version: - + + Sync version: + + Build date: