Keep updating the last seen id correctly

This commit is contained in:
Andras Schmelczer 2025-04-08 23:02:41 +01:00
parent f63d3dd830
commit 96bf542b91
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
3 changed files with 66 additions and 41 deletions

View file

@ -59,7 +59,7 @@ export class UnrestrictedSyncer {
document
);
this.tryIncrementVaultUpdateId(response.vaultUpdateId);
this.database.addLastSeenUpdateId(response.vaultUpdateId);
}
);
}
@ -90,6 +90,8 @@ export class UnrestrictedSyncer {
},
document
);
this.database.addLastSeenUpdateId(response.vaultUpdateId);
}
);
}
@ -156,6 +158,7 @@ export class UnrestrictedSyncer {
this.logger.info(
`Document ${document.relativePath} has been deleted before we could finish updating it`
);
this.database.addLastSeenUpdateId(response.vaultUpdateId);
return;
}
@ -174,6 +177,7 @@ export class UnrestrictedSyncer {
this.logger.debug(
`Document ${document.relativePath} is already more up to date than the fetched version`
);
this.database.addLastSeenUpdateId(response.vaultUpdateId); // in case the previous `vaultUpdateId` update hasn't made it through
return;
}
@ -206,7 +210,7 @@ export class UnrestrictedSyncer {
await this.operations.delete(document.relativePath);
this.tryIncrementVaultUpdateId(response.vaultUpdateId);
this.database.addLastSeenUpdateId(response.vaultUpdateId);
return;
}
@ -221,14 +225,6 @@ export class UnrestrictedSyncer {
); // this can throw FileNotFoundError
}
this.database.updateDocumentMetadata(
{
parentVersionId: response.vaultUpdateId,
hash: contentHash
},
document
);
if (
!("type" in response) ||
response.type === "MergingUpdate"
@ -268,7 +264,7 @@ export class UnrestrictedSyncer {
);
}
this.tryIncrementVaultUpdateId(response.vaultUpdateId);
this.database.addLastSeenUpdateId(response.vaultUpdateId);
}
);
}
@ -291,6 +287,7 @@ export class UnrestrictedSyncer {
this.logger.debug(
`Document ${remoteVersion.relativePath} is already at least as up to date as the fetched version`
);
return;
}
@ -425,10 +422,4 @@ export class UnrestrictedSyncer {
}
}
}
private tryIncrementVaultUpdateId(responseVaultUpdateId: number): void {
if (this.database.getLastSeenUpdateId() === responseVaultUpdateId - 1) {
this.database.setLastSeenUpdateId(responseVaultUpdateId);
}
}
}