dispose attachment blobs when pending event is removed/closing session

This commit is contained in:
Bruno Windels 2020-11-18 20:08:42 +01:00
parent f6dbb23f79
commit fba5877b3b
4 changed files with 22 additions and 0 deletions

View File

@ -89,6 +89,11 @@ export class AttachmentUpload {
setPath(`${prefix}url`, content, this._mxcUrl);
}
}
dispose() {
this._unencryptedBlob.dispose();
this._transferredBlob.dispose();
}
}
function setPath(path, content, value) {

View File

@ -640,6 +640,7 @@ export class Room extends EventEmitter {
dispose() {
this._roomEncryption?.dispose();
this._timeline?.dispose();
this._sendQueue.dispose();
}
}

View File

@ -152,4 +152,12 @@ export class PendingEvent {
this._status = SendStatus.Sent;
this._emitUpdate("status");
}
dispose() {
if (this._attachments) {
for (const attachment of Object.values(this._attachments)) {
attachment.dispose();
}
}
}
}

View File

@ -121,6 +121,7 @@ export class SendQueue {
await txn.complete();
this._pendingEvents.remove(idx);
}
pendingEvent.dispose();
}
emitRemovals(pendingEvents) {
@ -129,6 +130,7 @@ export class SendQueue {
if (idx !== -1) {
this._pendingEvents.remove(idx);
}
pendingEvent.dispose();
}
}
@ -201,4 +203,10 @@ export class SendQueue {
await txn.complete();
return pendingEvent;
}
dispose() {
for (const pe in this._pendingEvents.array) {
pe.dispose();
}
}
}