sync fixes

This commit is contained in:
zadam 2021-02-11 22:50:32 +01:00
parent 8850de51f5
commit 3d7beefad0
4 changed files with 19 additions and 1 deletions

View file

@ -0,0 +1,5 @@
UPDATE entity_changes SET isSynced = (
SELECT options.isSynced
FROM options
WHERE options.name = entity_changes.entityId
) WHERE entityName = 'options';

View file

@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 180;
const APP_DB_VERSION = 181;
const SYNC_VERSION = 19;
const CLIPPER_PROTOCOL_VERSION = "1.0";

View file

@ -1,4 +1,5 @@
const sql = require('./sql');
const log = require('./log');
const entityChangesService = require('./entity_changes.js');
const eventService = require('./events');
const entityConstructor = require('../entities/entity_constructor');
@ -6,6 +7,18 @@ const entityConstructor = require('../entities/entity_constructor');
function updateEntity(entityChange, entity, sourceId) {
// can be undefined for options with isSynced=false
if (!entity) {
if (entityChange.isSynced) {
if (entityChange.isErased) {
entityChangesService.addEntityChange(entityChange, sourceId);
}
else {
log.info(`Encountered synced non-erased entity change without entity: ${JSON.stringify(entityChange)}`);
}
}
else if (entityChange.entityName !== 'options') {
log.info(`Encountered unsynced non-option entity change without entity: ${JSON.stringify(entityChange)}`);
}
return;
}