From 1400ec9c16721ad0dfd9786f20d8a78fa8d43008 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:10:09 -0500 Subject: [PATCH] [PM-6853] Stop Caching Empty Ciphers List (#8406) * Stop Caching Empty Ciphers List * Allow Caching `null` * Move Logic to CipherService --- libs/common/src/vault/services/cipher.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index b3deed7c0c..8a86d9aa05 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -79,7 +79,12 @@ export class CipherService implements CipherServiceAbstraction { } async setDecryptedCipherCache(value: CipherView[]) { - await this.stateService.setDecryptedCiphers(value); + // Sometimes we might prematurely decrypt the vault and that will result in no ciphers + // if we cache it then we may accidentially return it when it's not right, we'd rather try decryption again. + // We still want to set null though, that is the indicator that the cache isn't valid and we should do decryption. + if (value == null || value.length !== 0) { + await this.stateService.setDecryptedCiphers(value); + } if (this.searchService != null) { if (value == null) { this.searchService.clearIndex();