From 8b320bb85faa6dc965400c47549d1828e762a06c Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 13 Nov 2019 22:32:14 +0100 Subject: [PATCH] force note sync now really forces update on other instances by updating utcDateModified --- src/routes/api/sync.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/routes/api/sync.js b/src/routes/api/sync.js index 8bc919566..e3e6d62da 100644 --- a/src/routes/api/sync.js +++ b/src/routes/api/sync.js @@ -9,6 +9,7 @@ const optionService = require('../../services/options'); const contentHashService = require('../../services/content_hash'); const log = require('../../services/log'); const syncOptions = require('../../services/sync_options'); +const dateUtils = require('../../services/date_utils'); async function testSync() { try { @@ -74,19 +75,31 @@ async function forceFullSync() { async function forceNoteSync(req) { const noteId = req.params.noteId; + const now = dateUtils.utcNowDateTime(); + + await sql.execute(`UPDATE notes SET utcDateModified = ? WHERE noteId = ?`, [now, noteId]); await syncTableService.addNoteSync(noteId); + + await sql.execute(`UPDATE note_contents SET utcDateModified = ? WHERE noteId = ?`, [now, noteId]); await syncTableService.addNoteContentSync(noteId); for (const branchId of await sql.getColumn("SELECT branchId FROM branches WHERE noteId = ?", [noteId])) { + await sql.execute(`UPDATE branches SET utcDateModified = ? WHERE branchId = ?`, [now, branchId]); + await syncTableService.addBranchSync(branchId); } for (const attributeId of await sql.getColumn("SELECT attributeId FROM attributes WHERE noteId = ?", [noteId])) { + await sql.execute(`UPDATE attributes SET utcDateModified = ? WHERE attributeId = ?`, [now, attributeId]); + await syncTableService.addAttributeSync(attributeId); } for (const noteRevisionId of await sql.getColumn("SELECT noteRevisionId FROM note_revisions WHERE noteId = ?", [noteId])) { + await sql.execute(`UPDATE note_revisions SET utcDateModified = ? WHERE noteRevisionId = ?`, [now, noteRevisionId]); await syncTableService.addNoteRevisionSync(noteRevisionId); + + await sql.execute(`UPDATE note_revision_contents SET utcDateModified = ? WHERE noteRevisionId = ?`, [now, noteRevisionId]); await syncTableService.addNoteRevisionContentSync(noteRevisionId); }