From d39cdbfada2d9455580504267f0a466ae792b7ab Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 25 Jul 2018 10:57:36 +0200 Subject: [PATCH] better instructions for desktop => server instance sync setup, plus some sync fixes --- src/public/javascripts/setup.js | 4 ++++ src/services/options_init.js | 2 +- src/services/sync.js | 12 +++++++++--- src/views/index.ejs | 2 +- src/views/setup.ejs | 11 ++++++++++- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/public/javascripts/setup.js b/src/public/javascripts/setup.js index daccd98ef..06cc3dd0d 100644 --- a/src/public/javascripts/setup.js +++ b/src/public/javascripts/setup.js @@ -5,6 +5,10 @@ function SetupModel() { setInterval(checkOutstandingSyncs, 1000); } + const serverAddress = location.protocol + '//' + location.host; + + $("#current-host").html(serverAddress); + this.step = ko.observable(syncInProgress ? "sync-in-progress" : "setup-type"); this.setupType = ko.observable(); diff --git a/src/services/options_init.js b/src/services/options_init.js index c54e55fb9..c8ab364df 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -29,7 +29,7 @@ async function initSyncedOptions(username, password) { await passwordEncryptionService.setDataKey(password, utils.randomSecureToken(16)); } -async function initNotSyncedOptions(initialized, startNotePath = '', syncServerHost = '', syncProxy = '') { +async function initNotSyncedOptions(initialized, startNotePath = 'root', syncServerHost = '', syncProxy = '') { await optionService.createOption('startNotePath', startNotePath, false); await optionService.createOption('lastBackupDate', dateUtils.nowDate(), false); await optionService.createOption('dbVersion', appInfo.dbVersion, false); diff --git a/src/services/sync.js b/src/services/sync.js index c4331b5a2..a36794f6e 100644 --- a/src/services/sync.js +++ b/src/services/sync.js @@ -131,6 +131,12 @@ async function pushSync(syncContext) { while (true) { const syncs = await sql.getRows('SELECT * FROM sync WHERE id > ? LIMIT 1000', [lastSyncedPush]); + if (syncs.length === 0) { + log.info("Nothing to push"); + + break; + } + const filteredSyncs = syncs.filter(sync => { if (sync.sourceId === syncContext.sourceId) { // too noisy @@ -149,11 +155,11 @@ async function pushSync(syncContext) { }); if (filteredSyncs.length === 0) { - log.info("Nothing to push"); - + // there still might be more syncs (because of batch limit), just all from current batch + // has been filtered out await setLastSyncedPush(lastSyncedPush); - break; + continue; } const syncRecords = await getSyncRecords(filteredSyncs); diff --git a/src/views/index.ejs b/src/views/index.ejs index 672ea6de1..b8d931653 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -410,7 +410,7 @@
- +
diff --git a/src/views/setup.ejs b/src/views/setup.ejs index 25f131370..83dd3933c 100644 --- a/src/views/setup.ejs +++ b/src/views/setup.ejs @@ -57,7 +57,16 @@

Sync from Desktop

-

This setup needs to be initiated from the desktop instance, please open it, go to settings in the top right, click on sync tab and then click on Setup sync with server instance.

+

This setup needs to be initiated from the desktop instance:

+ +
    +
  1. please open your desktop instance of Trilium Notes
  2. +
  3. click on Options button in the top right
  4. +
  5. click on Sync tab
  6. +
  7. configure server instance address to the: and click save.
  8. +
  9. click on "Sync document to the server instance" button
  10. +
  11. once you've done all this, click here
  12. +