mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
make flushing room key shares reentrant
as it can be called from Room.start while still running.
This commit is contained in:
parent
bcca23bac9
commit
134b04c782
@ -54,6 +54,7 @@ export class RoomEncryption {
|
|||||||
this._notifyMissingMegolmSession = notifyMissingMegolmSession;
|
this._notifyMissingMegolmSession = notifyMissingMegolmSession;
|
||||||
this._clock = clock;
|
this._clock = clock;
|
||||||
this._disposed = false;
|
this._disposed = false;
|
||||||
|
this._isFlushingRoomKeyShares = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async enableSessionBackup(sessionBackup) {
|
async enableSessionBackup(sessionBackup) {
|
||||||
@ -321,6 +322,12 @@ export class RoomEncryption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async flushPendingRoomKeyShares(hsApi, operations = null) {
|
async flushPendingRoomKeyShares(hsApi, operations = null) {
|
||||||
|
// this has to be reentrant as it can be called from Room.start while still running
|
||||||
|
if (this._isFlushingRoomKeyShares) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._isFlushingRoomKeyShares = true;
|
||||||
|
try {
|
||||||
if (!operations) {
|
if (!operations) {
|
||||||
const txn = await this._storage.readTxn([this._storage.storeNames.operations]);
|
const txn = await this._storage.readTxn([this._storage.storeNames.operations]);
|
||||||
operations = await txn.operations.getAllByTypeAndScope("share_room_key", this._room.id);
|
operations = await txn.operations.getAllByTypeAndScope("share_room_key", this._room.id);
|
||||||
@ -341,6 +348,9 @@ export class RoomEncryption {
|
|||||||
}
|
}
|
||||||
await removeTxn.complete();
|
await removeTxn.complete();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this._isFlushingRoomKeyShares = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _sendRoomKey(roomKeyMessage, devices, hsApi) {
|
async _sendRoomKey(roomKeyMessage, devices, hsApi) {
|
||||||
|
Loading…
Reference in New Issue
Block a user