mirror of
https://github.com/zadam/trilium.git
synced 2025-01-30 19:08:55 +08:00
configurable sync timeout
This commit is contained in:
parent
4efa00f36b
commit
5d5ea6a5c2
1 changed files with 8 additions and 7 deletions
|
@ -14,7 +14,7 @@ const notes = require('./notes');
|
||||||
|
|
||||||
const SYNC_SERVER = config['Sync']['syncServerHost'];
|
const SYNC_SERVER = config['Sync']['syncServerHost'];
|
||||||
const isSyncSetup = !!SYNC_SERVER;
|
const isSyncSetup = !!SYNC_SERVER;
|
||||||
|
const SYNC_TIMEOUT = config['Sync']['syncServerTimeout'] || 5000;
|
||||||
|
|
||||||
let syncInProgress = false;
|
let syncInProgress = false;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ async function pullSync(syncContext) {
|
||||||
uri: SYNC_SERVER + '/api/sync/changed?lastSyncId=' + lastSyncedPull + "&sourceId=" + SOURCE_ID,
|
uri: SYNC_SERVER + '/api/sync/changed?lastSyncId=' + lastSyncedPull + "&sourceId=" + SOURCE_ID,
|
||||||
jar: syncContext.cookieJar,
|
jar: syncContext.cookieJar,
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 5 * 1000
|
timeout: SYNC_TIMEOUT
|
||||||
});
|
});
|
||||||
|
|
||||||
logSync("Pulled " + syncRows.length + " changes");
|
logSync("Pulled " + syncRows.length + " changes");
|
||||||
|
@ -46,7 +46,8 @@ async function pullSync(syncContext) {
|
||||||
resp = await rp({
|
resp = await rp({
|
||||||
uri: SYNC_SERVER + "/api/sync/" + sync.entity_name + "/" + sync.entity_id,
|
uri: SYNC_SERVER + "/api/sync/" + sync.entity_name + "/" + sync.entity_id,
|
||||||
json: true,
|
json: true,
|
||||||
jar: syncContext.cookieJar
|
jar: syncContext.cookieJar,
|
||||||
|
timeout: SYNC_TIMEOUT
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -97,7 +98,7 @@ async function sendEntity(entity, entityName, cookieJar) {
|
||||||
uri: SYNC_SERVER + '/api/sync/' + entityName,
|
uri: SYNC_SERVER + '/api/sync/' + entityName,
|
||||||
body: payload,
|
body: payload,
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 5 * 1000,
|
timeout: SYNC_TIMEOUT,
|
||||||
jar: cookieJar
|
jar: cookieJar
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -189,7 +190,7 @@ async function login() {
|
||||||
hash: hash
|
hash: hash
|
||||||
},
|
},
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 5 * 1000,
|
timeout: SYNC_TIMEOUT,
|
||||||
jar: cookieJar
|
jar: cookieJar
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -388,8 +389,8 @@ async function updateRecentNotes(entity, sourceId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SYNC_SERVER) {
|
if (isSyncSetup) {
|
||||||
log.info("Setting up sync");
|
log.info("Setting up sync to " + SYNC_SERVER + " with timeout " + SYNC_TIMEOUT);
|
||||||
|
|
||||||
setInterval(sync, 60000);
|
setInterval(sync, 60000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue