1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Always migrate inbound group sessions

This commit is contained in:
David Baker
2018-01-02 13:31:57 +00:00
parent e5086f22d6
commit c43ccb860b

View File

@@ -223,37 +223,30 @@ OlmDevice.prototype._migrateFromSessionStore = async function() {
let numIbSessions = 0; let numIbSessions = 0;
await this._cryptoStore.doTxn( await this._cryptoStore.doTxn(
'readwrite', [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS], (txn) => { 'readwrite', [IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS], (txn) => {
this._cryptoStore.countEndToEndInboundGroupSessions(txn, (count) => { // We always migrate inbound group sessions, even if we already have some
if (count) { // in the new store. They should be be safe to migrate.
console.log( for (const s of ibGroupSessions) {
"Cryto store already has inbound group sessions: "+ try {
"not migrating", this._cryptoStore.addEndToEndInboundGroupSession(
s.senderKey, s.sessionId,
JSON.parse(
this._sessionStore.getEndToEndInboundGroupSession(
s.senderKey, s.sessionId,
),
), txn,
);
} catch (e) {
console.warn(
"Failed to import session " + s.senderKey + "/" +
s.sessionId + ": " + e.stack || e,
); );
return;
} }
for (const s of ibGroupSessions) { ++numIbSessions;
try { }
this._cryptoStore.addEndToEndInboundGroupSession( console.log(
s.senderKey, s.sessionId, "Migrating " + numIbSessions +
JSON.parse( " inbound group sessions from session store",
this._sessionStore.getEndToEndInboundGroupSession( );
s.senderKey, s.sessionId,
),
), txn,
);
} catch (e) {
console.warn(
"Failed to import session " + s.senderKey + "/" +
s.sessionId + ": " + e.stack || e,
);
}
++numIbSessions;
}
console.log(
"Migrating " + numIbSessions +
" inbound group sessions from session store",
);
});
}, },
); );
this._sessionStore.removeAllEndToEndInboundGroupSessions(); this._sessionStore.removeAllEndToEndInboundGroupSessions();