ensure olm Account in dehydrated device is freed on error

This commit is contained in:
Bruno Windels 2021-10-28 11:52:32 +02:00
parent bef12c7a8f
commit 544019f67d
2 changed files with 8 additions and 1 deletions

View File

@ -189,6 +189,8 @@ export class SessionContainer {
log.set("status", this._status.get());
} catch (err) {
log.catch(err);
// free olm Account that might be contained
dehydratedDevice?.dispose();
this._error = err;
this._status.set(LoadStatus.Error);
}

View File

@ -90,11 +90,16 @@ class DehydratedDevice {
// make it clear that ownership is transfered upon calling this
adoptUnpickledOlmAccount() {
const account = this._account;
this._account = null;
this._account = undefined;
return account;
}
get deviceId() {
return this._dehydratedDevice.device_id;
}
dispose() {
this._account?.free();
this._account = undefined;
}
}