forked from mystiq/hydrogen-web
Merge pull request #523 from vector-im/bwindels/clear-cache-after-515
clear history cache to purge potential timeline corruption from #515
This commit is contained in:
commit
4cebe26186
1 changed files with 28 additions and 1 deletions
|
@ -30,7 +30,8 @@ export const schema: MigrationFunc[] = [
|
||||||
createTimelineRelationsStore,
|
createTimelineRelationsStore,
|
||||||
fixMissingRoomsInUserIdentities,
|
fixMissingRoomsInUserIdentities,
|
||||||
changeSSSSKeyPrefix,
|
changeSSSSKeyPrefix,
|
||||||
backupAndRestoreE2EEAccountToLocalStorage
|
backupAndRestoreE2EEAccountToLocalStorage,
|
||||||
|
clearAllStores
|
||||||
];
|
];
|
||||||
// TODO: how to deal with git merge conflicts of this array?
|
// TODO: how to deal with git merge conflicts of this array?
|
||||||
|
|
||||||
|
@ -243,3 +244,29 @@ async function backupAndRestoreE2EEAccountToLocalStorage(db: IDBDatabase, txn: I
|
||||||
const restored = await sessionStore.tryRestoreE2EEIdentityFromLocalStorage(log);
|
const restored = await sessionStore.tryRestoreE2EEIdentityFromLocalStorage(log);
|
||||||
log.set("restored", restored);
|
log.set("restored", restored);
|
||||||
}
|
}
|
||||||
|
// v14 clear all stores apart from e2ee keys because of possible timeline corruption in #515, will trigger initial sync
|
||||||
|
async function clearAllStores(db: IDBDatabase, txn: IDBTransaction) {
|
||||||
|
for (const storeName of db.objectStoreNames) {
|
||||||
|
const store = txn.objectStore(storeName);
|
||||||
|
switch (storeName) {
|
||||||
|
case "inboundGroupSessions":
|
||||||
|
case "outboundGroupSessions":
|
||||||
|
case "olmSessions":
|
||||||
|
case "operations":
|
||||||
|
continue;
|
||||||
|
case "session": {
|
||||||
|
await iterateCursor(store.openCursor(), (value, key, cursor) => {
|
||||||
|
if (!(key as string).startsWith(SESSION_E2EE_KEY_PREFIX)) {
|
||||||
|
cursor.delete();
|
||||||
|
}
|
||||||
|
return NOT_DONE;
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
store.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue