fix sync issues

This commit is contained in:
zadam 2020-03-11 22:43:20 +01:00
parent 2d38706ba8
commit 48abd765c6
4 changed files with 8 additions and 8 deletions

View File

@ -6,8 +6,8 @@ CREATE TABLE IF NOT EXISTS "sync_mig" (
`isSynced` INTEGER default 0 not null, `isSynced` INTEGER default 0 not null,
`utcSyncDate` TEXT NOT NULL); `utcSyncDate` TEXT NOT NULL);
INSERT INTO sync_mig (entityName, entityId, sourceId, isSynced, utcSyncDate) INSERT INTO sync_mig (id, entityName, entityId, sourceId, isSynced, utcSyncDate)
SELECT entityName, entityId, sourceId, 1, utcSyncDate FROM sync; SELECT id, entityName, entityId, sourceId, 1, utcSyncDate FROM sync;
DROP TABLE sync; DROP TABLE sync;

View File

@ -51,7 +51,7 @@ class ConsistencyChecks {
childToParents[childNoteId].push(parentNoteId); childToParents[childNoteId].push(parentNoteId);
} }
function checkTreeCycle(noteId, path) { const checkTreeCycle = (noteId, path) => {
if (noteId === 'root') { if (noteId === 'root') {
return; return;
} }
@ -75,7 +75,7 @@ class ConsistencyChecks {
checkTreeCycle(parentNoteId, newPath); checkTreeCycle(parentNoteId, newPath);
} }
} }
} };
const noteIds = Object.keys(childToParents); const noteIds = Object.keys(childToParents);

View File

@ -112,7 +112,7 @@ async function updateEntity(entity) {
if (entity.isChanged) { if (entity.isChanged) {
const isSynced = entityName !== 'options' || entity.isSynced; const isSynced = entityName !== 'options' || entity.isSynced;
await syncTableService.addEntitySync(entityName, primaryKey, isSynced); await syncTableService.addEntitySync(entityName, primaryKey, null, isSynced);
if (!cls.isEntityEventsDisabled()) { if (!cls.isEntityEventsDisabled()) {
const eventPayload = { const eventPayload = {

View File

@ -10,13 +10,13 @@ const cls = require('./cls');
let maxSyncId = 0; let maxSyncId = 0;
async function insertEntitySync(entityName, entityId, sourceId, isSynced) { async function insertEntitySync(entityName, entityId, sourceId = null, isSynced = true) {
const sync = { const sync = {
entityName: entityName, entityName: entityName,
entityId: entityId, entityId: entityId,
utcSyncDate: dateUtils.utcNowDateTime(), utcSyncDate: dateUtils.utcNowDateTime(),
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(), sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(),
isSynced: isSynced isSynced: isSynced ? 1 : 0
}; };
sync.id = await sql.replace("sync", sync); sync.id = await sql.replace("sync", sync);
@ -26,7 +26,7 @@ async function insertEntitySync(entityName, entityId, sourceId, isSynced) {
return sync; return sync;
} }
async function addEntitySync(entityName, entityId, sourceId, isSynced = true) { async function addEntitySync(entityName, entityId, sourceId, isSynced) {
const sync = await insertEntitySync(entityName, entityId, sourceId, isSynced); const sync = await insertEntitySync(entityName, entityId, sourceId, isSynced);
cls.addSyncRow(sync); cls.addSyncRow(sync);