Clarify when memory stores are being used

This adds logging for the cases where memory only stores are being used. It also
reorganises the sync store path to match the crypto store.

Part of https://github.com/vector-im/riot-web/issues/9309
This commit is contained in:
J. Ryan Stinnett 2019-03-28 12:40:38 +00:00 committed by Travis Ralston
parent 4c65587469
commit 83931a4a42

View file

@ -62,15 +62,9 @@ export async function checkConsistency() {
} }
if (indexedDB && localStorage) { if (indexedDB && localStorage) {
try { const results = await checkSyncStore();
const dataInSyncStore = await Matrix.IndexedDBStore.exists( if (!results.healthy) {
indexedDB, SYNC_STORE_NAME,
);
log(`Sync store contains data? ${dataInSyncStore}`);
} catch (e) {
healthy = false; healthy = false;
error("Sync store inaccessible", e);
track("Sync store inaccessible");
} }
} else { } else {
healthy = false; healthy = false;
@ -108,6 +102,22 @@ export async function checkConsistency() {
} }
} }
async function checkSyncStore() {
let exists = false;
try {
exists = await Matrix.IndexedDBStore.exists(
indexedDB, SYNC_STORE_NAME,
);
log(`Sync store using IndexedDB contains data? ${exists}`);
return { exists, healthy: true };
} catch (e) {
error("Sync store using IndexedDB inaccessible", e);
track("Sync store using IndexedDB inaccessible");
}
log("Sync store using memory only");
return { exists, healthy: false };
}
async function checkCryptoStore() { async function checkCryptoStore() {
let exists = false; let exists = false;
try { try {
@ -128,5 +138,6 @@ async function checkCryptoStore() {
error("Crypto store using local storage inaccessible", e); error("Crypto store using local storage inaccessible", e);
track("Crypto store using local storage inaccessible"); track("Crypto store using local storage inaccessible");
} }
log("Crypto store using memory only");
return { exists, healthy: false }; return { exists, healthy: false };
} }