mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync login now includes check for sync server initialization and initializes it if necessary
Test sync button strictly not necessary
This commit is contained in:
parent
e4381d10e8
commit
eb84cfbef2
@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const syncService = require('../../services/sync');
|
const syncService = require('../../services/sync');
|
||||||
const setupService = require('../../services/setup');
|
|
||||||
const syncUpdateService = require('../../services/sync_update');
|
const syncUpdateService = require('../../services/sync_update');
|
||||||
const syncTableService = require('../../services/sync_table');
|
const syncTableService = require('../../services/sync_table');
|
||||||
const sql = require('../../services/sql');
|
const sql = require('../../services/sql');
|
||||||
@ -12,16 +11,13 @@ const log = require('../../services/log');
|
|||||||
|
|
||||||
async function testSync() {
|
async function testSync() {
|
||||||
try {
|
try {
|
||||||
if (await setupService.isSyncServerInitialized()) {
|
await syncService.login();
|
||||||
await syncService.login();
|
|
||||||
|
|
||||||
return { success: true, message: "Sync server handshake has been successful" };
|
// login was successful so we'll kick off sync now
|
||||||
}
|
// this is important in case when sync server has been just initialized
|
||||||
else {
|
syncService.sync();
|
||||||
await setupService.setupSyncToSyncServer();
|
|
||||||
|
|
||||||
return { success: true, message: "Sync has been established to the server instance. It will take some time to finish." };
|
return { success: true, message: "Sync server handshake has been successful, sync has been started." };
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return {
|
return {
|
||||||
|
@ -33,8 +33,6 @@ async function setupSyncToSyncServer() {
|
|||||||
// the previous request would have failed.
|
// the previous request would have failed.
|
||||||
await optionService.setOption('lastSyncedPush', 0);
|
await optionService.setOption('lastSyncedPush', 0);
|
||||||
await optionService.setOption('lastSyncedPull', 0);
|
await optionService.setOption('lastSyncedPull', 0);
|
||||||
|
|
||||||
syncService.sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function requestToSyncServer(method, path, body = null) {
|
async function requestToSyncServer(method, path, body = null) {
|
||||||
|
@ -69,6 +69,16 @@ async function sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
|
const setupService = require('./setup'); // circular dependency issue
|
||||||
|
|
||||||
|
if (!await setupService.isSyncServerInitialized()) {
|
||||||
|
await setupService.setupSyncToSyncServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
return await doLogin();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doLogin() {
|
||||||
const timestamp = dateUtils.nowDate();
|
const timestamp = dateUtils.nowDate();
|
||||||
|
|
||||||
const documentSecret = await optionService.getOption('documentSecret');
|
const documentSecret = await optionService.getOption('documentSecret');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user