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 9b41ad8 commit 0a45108
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 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,27 @@ 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.clearCache();
*/
await this.stateService.setEncryptedCiphers(ciphers);

// Cozy customization
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);
// Cozy customization end
}

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

0 comments on commit 0a45108

Please sign in to comment.