mirror of
https://github.com/zadam/trilium.git
synced 2025-01-01 12:52:17 +08:00
sync fixes
This commit is contained in:
parent
8850de51f5
commit
3d7beefad0
4 changed files with 19 additions and 1 deletions
5
db/migrations/0181__fix_entityChanges_isSynced.sql
Normal file
5
db/migrations/0181__fix_entityChanges_isSynced.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
UPDATE entity_changes SET isSynced = (
|
||||
SELECT options.isSynced
|
||||
FROM options
|
||||
WHERE options.name = entity_changes.entityId
|
||||
) WHERE entityName = 'options';
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue