From c65e8bea1113a588ec807d776770cb4b9a58335f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 10 Nov 2020 19:05:50 +0100 Subject: [PATCH] clean up properly --- assets/download-sandbox.html | 1 + src/domain/session/room/timeline/tiles/FileTile.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/download-sandbox.html b/assets/download-sandbox.html index ecb4886e..d8b26fad 100644 --- a/assets/download-sandbox.html +++ b/assets/download-sandbox.html @@ -12,6 +12,7 @@ link.href = url; link.download = filename; link.click(); + URL.revokeObjectURL(url); } window.addEventListener("message", function(event) { if (event.data.type === "download") { diff --git a/src/domain/session/room/timeline/tiles/FileTile.js b/src/domain/session/room/timeline/tiles/FileTile.js index 2891e8be..b2afd728 100644 --- a/src/domain/session/room/timeline/tiles/FileTile.js +++ b/src/domain/session/room/timeline/tiles/FileTile.js @@ -33,12 +33,14 @@ export class FileTile extends MessageTile { const filename = content.body; this._downloading = true; this.emitChange("label"); + let bufferHandle; try { - const bufferHandle = await this._mediaRepository.downloadAttachment(content); + bufferHandle = await this._mediaRepository.downloadAttachment(content); this.platform.offerSaveBufferHandle(bufferHandle, filename); } catch (err) { this._error = err; } finally { + bufferHandle?.dispose(); this._downloading = false; } this.emitChange("label");