From b127b788b2622fc8b409288f09c200cc03143cd5 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 7 Mar 2024 22:54:50 +0100 Subject: [PATCH] Fixed download bug - Fixed: Multiple files could not be downloaded due to a caching issue --- frontend/src/app/download/download.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/download/download.component.ts b/frontend/src/app/download/download.component.ts index c2546fd..8e23240 100644 --- a/frontend/src/app/download/download.component.ts +++ b/frontend/src/app/download/download.component.ts @@ -172,12 +172,20 @@ export class DownloadComponent { const blob = new Blob([response.data], {type: 'application/octet-stream'}); const url = window.URL.createObjectURL(blob); - const a = document.createElement('a'); + + // Check if download blob already exists and remove it if it does + let a = document.getElementById('fileDownloadBlob') as HTMLAnchorElement | null; + if (a !== null) { + a.remove(); + } + + a = document.createElement('a'); a.style.display = 'none'; a.href = url; a.download = filename; a.id = 'fileDownloadBlob'; document.body.appendChild(a); + this.saveDownloadedFile(); // Clean up by revoking the Blob URL and removing the temporary anchor (currently disabled due to saveDownloadBtn)