mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 03:27:44 +08:00
small refactors in sync
This commit is contained in:
parent
701911b766
commit
4b779d7512
2 changed files with 30 additions and 37 deletions
|
@ -8,7 +8,7 @@ const becca = require("../becca/becca");
|
|||
|
||||
let maxEntityChangeId = 0;
|
||||
|
||||
function addEntityChangeWithinstanceId(origEntityChange, instanceId) {
|
||||
function addEntityChangeWithInstanceId(origEntityChange, instanceId) {
|
||||
const ec = {...origEntityChange, instanceId};
|
||||
|
||||
return addEntityChange(ec);
|
||||
|
@ -85,7 +85,6 @@ function cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey) {
|
|||
}
|
||||
|
||||
function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
||||
try {
|
||||
cleanupEntityChangesForMissingEntities(entityName, entityPrimaryKey);
|
||||
|
||||
sql.transactional(() => {
|
||||
|
@ -118,12 +117,6 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
|||
log.info(`Created ${createdCount} missing entity changes for ${entityName}.`);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
// this is to fix migration from 0.30 to 0.32, can be removed later
|
||||
// see https://github.com/zadam/trilium/issues/557
|
||||
log.error(`Filling entity changes failed for ${entityName} ${entityPrimaryKey} with error "${e.message}", continuing`);
|
||||
}
|
||||
}
|
||||
|
||||
function fillAllEntityChanges() {
|
||||
|
@ -145,7 +138,7 @@ module.exports = {
|
|||
addNoteReorderingEntityChange,
|
||||
moveEntityChangeToTop,
|
||||
addEntityChange,
|
||||
addEntityChangeWithinstanceId,
|
||||
addEntityChangeWithInstanceId,
|
||||
fillAllEntityChanges,
|
||||
addEntityChangesForSector,
|
||||
getMaxEntityChangeId: () => maxEntityChangeId
|
||||
|
|
|
@ -54,7 +54,7 @@ function updateNormalEntity(remoteEntityChange, entity, instanceId) {
|
|||
|
||||
sql.execute(`DELETE FROM ${remoteEntityChange.entityName} WHERE ${primaryKey} = ?`, remoteEntityChange.entityId);
|
||||
|
||||
entityChangesService.addEntityChangeWithinstanceId(remoteEntityChange, instanceId);
|
||||
entityChangesService.addEntityChangeWithInstanceId(remoteEntityChange, instanceId);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -71,7 +71,7 @@ function updateNormalEntity(remoteEntityChange, entity, instanceId) {
|
|||
sql.transactional(() => {
|
||||
sql.replace(remoteEntityChange.entityName, entity);
|
||||
|
||||
entityChangesService.addEntityChangeWithinstanceId(remoteEntityChange, instanceId);
|
||||
entityChangesService.addEntityChangeWithInstanceId(remoteEntityChange, instanceId);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -86,7 +86,7 @@ function updateNoteReordering(entityChange, entity, instanceId) {
|
|||
sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?", [entity[key], key]);
|
||||
}
|
||||
|
||||
entityChangesService.addEntityChangeWithinstanceId(entityChange, instanceId);
|
||||
entityChangesService.addEntityChangeWithInstanceId(entityChange, instanceId);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -119,7 +119,7 @@ function eraseEntity(entityChange, instanceId) {
|
|||
|
||||
eventService.emit(eventService.ENTITY_DELETE_SYNCED, { entityName, entityId });
|
||||
|
||||
entityChangesService.addEntityChangeWithinstanceId(entityChange, instanceId);
|
||||
entityChangesService.addEntityChangeWithInstanceId(entityChange, instanceId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in a new issue