From 20f446936119e0dcba2c31deb8144fc788ddd133 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 28 Mar 2019 12:20:51 +0000 Subject: [PATCH] Add existence check to local storage based crypto store This supports additional diagnostics of stores in https://github.com/vector-im/riot-web/issues/9309. --- src/crypto/store/localStorage-crypto-store.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/crypto/store/localStorage-crypto-store.js b/src/crypto/store/localStorage-crypto-store.js index 4c30b6199..af6043af1 100644 --- a/src/crypto/store/localStorage-crypto-store.js +++ b/src/crypto/store/localStorage-crypto-store.js @@ -57,6 +57,16 @@ export default class LocalStorageCryptoStore extends MemoryCryptoStore { this.store = webStore; } + static exists(webStore) { + const length = webStore.length; + for (let i = 0; i < length; i++) { + if (webStore.key(i).startsWith(E2E_PREFIX)) { + return true; + } + } + return false; + } + // Olm Sessions countEndToEndSessions(txn, func) {