mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
check sync version before setting up the sync, fixes #559
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
const sqlInit = require('../../services/sql_init');
|
||||
const setupService = require('../../services/setup');
|
||||
const log = require('../../services/log');
|
||||
const appInfo = require('../../services/app_info');
|
||||
|
||||
async function getStatus() {
|
||||
return {
|
||||
isInitialized: await sqlInit.isDbInitialized(),
|
||||
schemaExists: await sqlInit.schemaExists()
|
||||
schemaExists: await sqlInit.schemaExists(),
|
||||
syncVersion: appInfo.syncVersion
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,7 +26,17 @@ async function setupSyncFromServer(req) {
|
||||
}
|
||||
|
||||
async function saveSyncSeed(req) {
|
||||
const options = req.body.options;
|
||||
const {options, syncVersion} = req.body;
|
||||
|
||||
if (appInfo.syncVersion !== syncVersion) {
|
||||
const message = `Could not setup sync since local sync protocol version is ${appInfo.syncVersion} while remote is ${syncVersion}. To fix this issue, use same Trilium version on all instances.`;
|
||||
|
||||
log.error(message);
|
||||
|
||||
return [400, {
|
||||
error: message
|
||||
}]
|
||||
}
|
||||
|
||||
await sqlInit.createDatabaseForSync(options);
|
||||
}
|
||||
@@ -32,7 +44,10 @@ async function saveSyncSeed(req) {
|
||||
async function getSyncSeed() {
|
||||
log.info("Serving sync seed.");
|
||||
|
||||
return await setupService.getSyncSeedOptions();
|
||||
return {
|
||||
options: await setupService.getSyncSeedOptions(),
|
||||
syncVersion: appInfo.syncVersion
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user