server: Clarify name

This commit is contained in:
Elian Doran 2024-07-15 19:31:59 +03:00
parent 81a2b206ca
commit ea47668916
No known key found for this signature in database

View File

@ -76,11 +76,11 @@ function updateEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instan
function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instanceId: string, updateContext: UpdateContext) { function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instanceId: string, updateContext: UpdateContext) {
const localEC = sql.getRow<EntityChange | undefined>(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [remoteEC.entityName, remoteEC.entityId]); const localEC = sql.getRow<EntityChange | undefined>(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [remoteEC.entityName, remoteEC.entityId]);
const localECIsOlderThanRemote = ( const localECIsOlderOrSameAsRemote = (
localEC && localEC.utcDateChanged && remoteEC.utcDateChanged && localEC && localEC.utcDateChanged && remoteEC.utcDateChanged &&
localEC.utcDateChanged <= remoteEC.utcDateChanged); localEC.utcDateChanged <= remoteEC.utcDateChanged);
if (!localEC || localECIsOlderThanRemote) { if (!localEC || localECIsOlderOrSameAsRemote) {
if (remoteEC.isErased) { if (remoteEC.isErased) {
if (localEC?.isErased) { if (localEC?.isErased) {
eraseEntity(remoteEC); // make sure it's erased anyway eraseEntity(remoteEC); // make sure it's erased anyway
@ -103,7 +103,7 @@ function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow,
} }
if (!localEC if (!localEC
|| localECIsOlderThanRemote || localECIsOlderOrSameAsRemote
|| localEC.hash !== remoteEC.hash || localEC.hash !== remoteEC.hash
|| localEC.isErased !== remoteEC.isErased || localEC.isErased !== remoteEC.isErased
) { ) {
@ -112,7 +112,7 @@ function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow,
return true; return true;
} else if ((localEC.hash !== remoteEC.hash || localEC.isErased !== remoteEC.isErased) } else if ((localEC.hash !== remoteEC.hash || localEC.isErased !== remoteEC.isErased)
&& !localECIsOlderThanRemote) { && !localECIsOlderOrSameAsRemote) {
// the change on our side is newer than on the other side, so the other side should update // the change on our side is newer than on the other side, so the other side should update
entityChangesService.putEntityChangeForOtherInstances(localEC); entityChangesService.putEntityChangeForOtherInstances(localEC);