mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix sync double initialization issue
This commit is contained in:
parent
e8797a137f
commit
9b425025c9
@ -6,7 +6,8 @@ const log = require('../../services/log');
|
||||
|
||||
async function getStatus() {
|
||||
return {
|
||||
isInitialized: await sqlInit.isDbInitialized()
|
||||
isInitialized: await sqlInit.isDbInitialized(),
|
||||
schemaExists: await sqlInit.schemaExists()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,10 @@ const repository = require('./repository');
|
||||
const optionService = require('./options');
|
||||
const syncOptions = require('./sync_options');
|
||||
|
||||
async function isSyncServerInitialized() {
|
||||
async function hasSyncServerSchemaAndSeed() {
|
||||
const response = await requestToSyncServer('GET', '/api/setup/status');
|
||||
|
||||
return response.isInitialized;
|
||||
return response.schemaExists;
|
||||
}
|
||||
|
||||
function triggerSync() {
|
||||
@ -23,7 +23,7 @@ function triggerSync() {
|
||||
});
|
||||
}
|
||||
|
||||
async function setupSyncToSyncServer() {
|
||||
async function sendSeedToSyncServer() {
|
||||
log.info("Initiating sync to server");
|
||||
|
||||
await requestToSyncServer('POST', '/api/setup/sync-seed', {
|
||||
@ -105,9 +105,9 @@ async function getSyncSeedOptions() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isSyncServerInitialized,
|
||||
hasSyncServerSchemaAndSeed,
|
||||
triggerSync,
|
||||
setupSyncToSyncServer,
|
||||
sendSeedToSyncServer,
|
||||
setupSyncFromSyncServer,
|
||||
getSyncSeedOptions
|
||||
};
|
@ -71,8 +71,8 @@ async function sync() {
|
||||
async function login() {
|
||||
const setupService = require('./setup'); // circular dependency issue
|
||||
|
||||
if (!await setupService.isSyncServerInitialized()) {
|
||||
await setupService.setupSyncToSyncServer();
|
||||
if (!await setupService.hasSyncServerSchemaAndSeed()) {
|
||||
await setupService.sendSeedToSyncServer();
|
||||
}
|
||||
|
||||
return await doLogin();
|
||||
|
Loading…
x
Reference in New Issue
Block a user