From c41448f5daef8741bc50f4736343282de4cb838c Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 15 Feb 2021 20:44:31 +0100 Subject: [PATCH] consistency check for wrong lastSyncedPush --- src/services/consistency_checks.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index f225f90a5..1125fbe03 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -538,6 +538,26 @@ class ConsistencyChecks { } } + findSyncIssues() { + const lastSyncedPush = parseInt(sql.getValue("SELECT value FROM options WHERE name = 'lastSyncedPush'")); + const maxEntityChangeId = sql.getValue("SELECT MAX(id) FROM entity_changes"); + + if (lastSyncedPush > maxEntityChangeId) { + if (this.autoFix) { + sql.execute("UPDATE options SET value = ? WHERE name = 'lastSyncedPush'", [maxEntityChangeId]); + + this.fixedIssues = true; + + logFix(`Fixed incorrect lastSyncedPush - was ${lastSyncedPush}, needs to be at maximum ${maxEntityChangeId}`); + } + else { + this.unrecoveredConsistencyErrors = true; + + logFix(`Incorrect lastSyncedPush - is ${lastSyncedPush}, needs to be at maximum ${maxEntityChangeId}`); + } + } + } + runAllChecksAndFixers() { this.unrecoveredConsistencyErrors = false; this.fixedIssues = false; @@ -552,6 +572,8 @@ class ConsistencyChecks { this.findWronglyNamedAttributes(); + this.findSyncIssues(); + // root branch should always be expanded sql.execute("UPDATE branches SET isExpanded = 1 WHERE branchId = 'root'");