mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
lower lastSyncedPull if server max sync ID is lower
This commit is contained in:
parent
c3913a8735
commit
0be173a8f7
@ -10,6 +10,7 @@ const appInfo = require('../../services/app_info');
|
|||||||
const eventService = require('../../services/events');
|
const eventService = require('../../services/events');
|
||||||
const cls = require('../../services/cls');
|
const cls = require('../../services/cls');
|
||||||
const sqlInit = require('../../services/sql_init');
|
const sqlInit = require('../../services/sql_init');
|
||||||
|
const sql = require('../../services/sql');
|
||||||
|
|
||||||
async function loginSync(req) {
|
async function loginSync(req) {
|
||||||
if (!await sqlInit.schemaExists()) {
|
if (!await sqlInit.schemaExists()) {
|
||||||
@ -44,7 +45,8 @@ async function loginSync(req) {
|
|||||||
req.session.loggedIn = true;
|
req.session.loggedIn = true;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sourceId: sourceIdService.getCurrentSourceId()
|
sourceId: sourceIdService.getCurrentSourceId(),
|
||||||
|
maxSyncId: await sql.getValue("SELECT MAX(id) FROM sync")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const url = require('url');
|
|
||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const sqlInit = require('./sql_init');
|
const sqlInit = require('./sql_init');
|
||||||
@ -99,6 +98,16 @@ async function doLogin() {
|
|||||||
|
|
||||||
syncContext.sourceId = resp.sourceId;
|
syncContext.sourceId = resp.sourceId;
|
||||||
|
|
||||||
|
const lastSyncedPull = await getLastSyncedPull();
|
||||||
|
|
||||||
|
// this is important in a scenario where we setup the sync by manually copying the document
|
||||||
|
// lastSyncedPull then could be pretty off for the newly cloned client
|
||||||
|
if (lastSyncedPull > resp.maxSyncId) {
|
||||||
|
log.info(`Lowering last synced pull from ${lastSyncedPull} to ${resp.maxSyncId}`);
|
||||||
|
|
||||||
|
await setLastSyncedPull(resp.maxSyncId);
|
||||||
|
}
|
||||||
|
|
||||||
return syncContext;
|
return syncContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user