Resend key requests when the keys change

This commit is contained in:
Jonas Lochmann 2022-11-21 01:00:00 +01:00
parent bedfd48a65
commit e103f6f072
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36

View file

@ -116,7 +116,9 @@ object CryptDataHandler {
database.cryptContainer().updateMetadata(updatedMetadata)
if (updatedMetadata.status == CryptContainerMetadata.ProcessingStatus.MissingKey && header != null) {
if (database.cryptContainerKeyRequest().byCryptContainerId(currentItem.cryptContainerId) == null) {
val existingRequest = database.cryptContainerKeyRequest().byCryptContainerId(currentItem.cryptContainerId)
if (existingRequest == null || existingRequest.requestTimeCryptContainerGeneration < header.generation) {
val signingKey = DeviceSigningKey.getPublicAndPrivateKeySync(database)!!.let { Curve25519.getPrivateKey(it) }
val requestKeyPair = Curve25519.generateKeyPair()
val sequenceNumber = database.config().getNextSigningSequenceNumberAndIncrementIt()
@ -143,6 +145,8 @@ object CryptDataHandler {
), database
)
if (existingRequest != null) database.cryptContainerKeyRequest().delete(existingRequest)
database.cryptContainerKeyRequest().insert(
CryptContainerPendingKeyRequest(
cryptContainerId = currentItem.cryptContainerId,