From ea50b2c40148350d66dd44b85183b09ff1c85ff2 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 17 Jul 2025 14:59:20 -0400 Subject: [PATCH] fix the firmware endpoint --- backend/endpoints/firmware.py | 6 +++--- backend/handler/filesystem/firmware_handler.py | 2 +- backend/handler/filesystem/roms_handler.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/endpoints/firmware.py b/backend/endpoints/firmware.py index 0ed61616c..5cae8b4fa 100644 --- a/backend/endpoints/firmware.py +++ b/backend/endpoints/firmware.py @@ -1,4 +1,4 @@ -from config import DISABLE_DOWNLOAD_ENDPOINT_AUTH, LIBRARY_BASE_PATH +from config import DISABLE_DOWNLOAD_ENDPOINT_AUTH from decorators.auth import protected_route from endpoints.responses import MessageResponse from endpoints.responses.firmware import AddFirmwareResponse, FirmwareSchema @@ -154,7 +154,7 @@ def head_firmware_content(request: Request, id: int, file_name: str): log.error(error) raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=error) - firmware_path = f"{LIBRARY_BASE_PATH}/{firmware.full_path}" + firmware_path = fs_firmware_handler.validate_path(firmware.full_path) return FileResponse( path=firmware_path, @@ -192,7 +192,7 @@ def get_firmware_content( log.error(error) raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=error) - firmware_path = f"{LIBRARY_BASE_PATH}/{firmware.full_path}" + firmware_path = fs_firmware_handler.validate_path(firmware.full_path) return FileResponse(path=firmware_path, filename=firmware.file_name) diff --git a/backend/handler/filesystem/firmware_handler.py b/backend/handler/filesystem/firmware_handler.py index 83b289e8c..7681f61a1 100644 --- a/backend/handler/filesystem/firmware_handler.py +++ b/backend/handler/filesystem/firmware_handler.py @@ -30,7 +30,7 @@ class FSFirmwareHandler(FSHandler): Args: platform: platform where firmware belong Returns: - list with all the filesystem firmware for a platform found in the LIBRARY_BASE_PATH + list with all the filesystem firmware for a platform """ firmware_path = self.get_firmware_fs_structure(platform_fs_slug) fs_firmware_files = self.list_files(path=firmware_path) diff --git a/backend/handler/filesystem/roms_handler.py b/backend/handler/filesystem/roms_handler.py index d1c796e4a..391234f09 100644 --- a/backend/handler/filesystem/roms_handler.py +++ b/backend/handler/filesystem/roms_handler.py @@ -403,7 +403,7 @@ class FSRomsHandler(FSHandler): rom_files.append( self._build_rom_file( - f_path.relative_to(LIBRARY_BASE_PATH), + f_path.relative_to(self.base_path), file_name, file_hash, ) @@ -536,12 +536,12 @@ class FSRomsHandler(FSHandler): Args: platform: platform where roms belong Returns: - list with all the filesystem roms for a platform found in the LIBRARY_BASE_PATH + list with all the filesystem roms for a platform """ rel_roms_path = self.get_roms_fs_structure( platform.fs_slug ) # Relative path to roms - abs_fs_path = f"{LIBRARY_BASE_PATH}/{rel_roms_path}" # Absolute path to roms + abs_fs_path = f"{self.base_path}/{rel_roms_path}" # Absolute path to roms fs_single_roms = self.list_files(path=abs_fs_path) fs_multi_roms = self.list_directories(path=abs_fs_path)