Skip to content

Commit

Permalink
feat: Updating instead of deleting cache when deleting cipher
Browse files Browse the repository at this point in the history
When deleting a cipher, we do not want to clear the cache because reconstructing the cache involves decrypting all ciphers which is very costly with our papers and contacts. Instead we manually update decrypted ciphers below.

Closing the cipher view after deleting a cipher was very slow before this commit.
  • Loading branch information
zatteo committed Apr 25, 2024
1 parent 29e1a79 commit 21d2f25
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libs/common/src/vault/services/cipher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,26 @@ export class CipherService implements CipherServiceAbstraction {
});
}

// Cozy customization
// We do not want to clear the cache because reconstructing the cache involves decrypting all ciphers
// which is very costly with our papers and contacts. Instead we manually update decrypted ciphers below.
//*
await this.stateService.setEncryptedCiphers(ciphers);

const decryptedCiphers = await this.stateService.getDecryptedCiphers();
if (decryptedCiphers == null) {
return;
}

const ids = typeof id === "string" ? [id] : id;
const removed = decryptedCiphers.filter((c) => !ids.includes(c.id));

await this.stateService.setDecryptedCiphers(removed);
/*/
await this.clearCache();
await this.stateService.setEncryptedCiphers(ciphers);
//*/
}

async deleteWithServer(id: string): Promise<any> {
Expand Down

0 comments on commit 21d2f25

Please sign in to comment.