support file picking in download

This commit is contained in:
Georges-Antoine Assi
2024-03-08 11:52:41 -05:00
parent 77e72621e0
commit 43ef2ddfeb
2 changed files with 8 additions and 4 deletions

View File

@@ -181,9 +181,13 @@ def get_rom_content(
rom = db_rom_handler.get_roms(id)
rom_path = f"{LIBRARY_BASE_PATH}/{rom.full_path}"
files_to_download = files or rom.files
if not rom.multi:
return FileResponse(path=rom_path, filename=file_name)
return FileResponse(path=rom_path, filename=rom.file_name)
if len(files_to_download) == 1:
return FileResponse(path=f"{rom_path}/{files_to_download[0]}", filename=files_to_download[0])
# Builds a generator of tuples for each member file
def local_files():
@@ -195,7 +199,7 @@ def get_rom_content(
except FileNotFoundError:
log.error(f"File {rom_path}/{f} not found!")
m3u_file = [str.encode(f"{rom.files[i]}\n") for i in range(len(rom.files))]
m3u_file = [str.encode(f"{files_to_download[i]}\n") for i in range(len(files_to_download))]
return [
(
f,
@@ -204,7 +208,7 @@ def get_rom_content(
ZIP_AUTO(os.path.getsize(f"{rom_path}/{f}")),
contents(f),
)
for f in rom.files
for f in files_to_download
] + [
(
f"{file_name}.m3u",

View File

@@ -130,7 +130,7 @@ async function downloadRom({
a.click();
// Only connect socket if multi-file download
if (rom.multi) {
if (rom.multi && files.length > 1) {
if (!socket.connected) socket.connect();
storeDownload().add(rom.id);