Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 4edb037

Browse files
committed
server: Fix "Content hash check for [...] sector [...] FAILED"
The issue was caused by a guard condition which prevented the writing of entity changes which came from the remote and were marked as deleted, resulting in an incorrect checksum when attempting to sync.
1 parent 2e9a624 commit 4edb037

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/services/sync_update.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ function updateEntities(entityChanges: EntityChangeRecord[], instanceId: string)
4141
atLeastOnePullApplied = true;
4242
}
4343

44-
if (entity) {
45-
updateEntity(entityChange, entity, instanceId, updateContext);
46-
}
44+
updateEntity(entityChange, entity, instanceId, updateContext);
4745
}
4846

4947
logUpdateContext(updateContext);
5048
}
5149

52-
function updateEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instanceId: string, updateContext: UpdateContext) {
50+
function updateEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow | undefined, instanceId: string, updateContext: UpdateContext) {
5351
if (!remoteEntityRow && remoteEC.entityName === 'options') {
5452
return; // can be undefined for options with isSynced=false
5553
}
@@ -74,7 +72,7 @@ function updateEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instan
7472
}
7573
}
7674

77-
function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow, instanceId: string, updateContext: UpdateContext) {
75+
function updateNormalEntity(remoteEC: EntityChange, remoteEntityRow: EntityRow | undefined, instanceId: string, updateContext: UpdateContext) {
7876
const localEC = sql.getRow<EntityChange | undefined>(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [remoteEC.entityName, remoteEC.entityId]);
7977
const localECIsOlderOrSameAsRemote = (
8078
localEC && localEC.utcDateChanged && remoteEC.utcDateChanged &&
@@ -139,7 +137,7 @@ function preProcessContent(remoteEC: EntityChange, remoteEntityRow: EntityRow) {
139137
}
140138
}
141139

142-
function updateNoteReordering(remoteEC: EntityChange, remoteEntityRow: EntityRow, instanceId: string) {
140+
function updateNoteReordering(remoteEC: EntityChange, remoteEntityRow: EntityRow | undefined, instanceId: string) {
143141
if (!remoteEntityRow) {
144142
throw new Error(`Empty note_reordering body for: ${JSON.stringify(remoteEC)}`);
145143
}

0 commit comments

Comments
 (0)