From a2e6c3e6128e15c203a8865a6fb3586875a6cc3c Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Wed, 1 Oct 2025 09:15:40 -0400 Subject: [PATCH] add comments --- backend/endpoints/rom.py | 4 ++-- frontend/src/services/api/rom.ts | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/backend/endpoints/rom.py b/backend/endpoints/rom.py index 4b404c6dd..dd1fa6a23 100644 --- a/backend/endpoints/rom.py +++ b/backend/endpoints/rom.py @@ -403,7 +403,7 @@ async def download_roms( for file in rom_files: content_lines.append( ZipContentLine( - crc32=None, + crc32=None, # The CRC hash stored for compressed files is for the uncompressed content size_bytes=file.file_size_bytes, encoded_location=quote(f"/library/{file.full_path}"), filename=file.full_path, @@ -637,7 +637,7 @@ async def get_rom_content( content_lines = [ ZipContentLine( - crc32=None, + crc32=None, # The CRC hash stored for compressed files is for the uncompressed content size_bytes=f.file_size_bytes, encoded_location=quote(f"/library/{f.full_path}"), filename=f.file_name_for_download(rom, hidden_folder), diff --git a/frontend/src/services/api/rom.ts b/frontend/src/services/api/rom.ts index f30b7649a..3252db2dc 100644 --- a/frontend/src/services/api/rom.ts +++ b/frontend/src/services/api/rom.ts @@ -229,25 +229,27 @@ async function bulkDownloadRoms({ roms: SimpleRom[]; filename?: string; }) { - if (roms.length === 0) return; + return new Promise((resolve) => { + if (roms.length === 0) return resolve(); - const romIds = roms.map((rom) => rom.id); + const romIds = roms.map((rom) => rom.id); - const queryParams = new URLSearchParams(); - queryParams.append("rom_ids", romIds.join(",")); - if (filename) queryParams.append("filename", filename); + const queryParams = new URLSearchParams(); + queryParams.append("rom_ids", romIds.join(",")); + if (filename) queryParams.append("filename", filename); - const a = document.createElement("a"); - a.href = `/api/roms/download?${queryParams.toString()}`; - a.style.display = "none"; + const a = document.createElement("a"); + a.href = `/api/roms/download?${queryParams.toString()}`; + a.style.display = "none"; - document.body.appendChild(a); - a.click(); + document.body.appendChild(a); + a.click(); - setTimeout(() => { - document.body.removeChild(a); - window.URL.revokeObjectURL(a.href); - }, DOWNLOAD_CLEANUP_DELAY); + setTimeout(() => { + document.body.removeChild(a); + resolve(); + }, DOWNLOAD_CLEANUP_DELAY); + }); } export type UpdateRom = SimpleRom & {