From 907641d7e3479ef4830431ced3c24d003f8d9621 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 21 Dec 2025 02:10:47 +0800 Subject: [PATCH] Fix catalogue path initialization for non-MuOS/non-SpruceOS devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change ensures that the catalogue directory is properly configured and created for devices running generic EmulationStation setups (such as Knulli on PortMaster), preventing download errors when the catalogue path is not initialized. Changes: - Add CATALOGUE_PATH environment variable support - Set default catalogue path in app directory - Auto-create catalogue directory if it doesn't exist - Graceful error handling if directory creation fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- RomM/filesystem.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/RomM/filesystem.py b/RomM/filesystem.py index 4bf9f7f..e7290b7 100644 --- a/RomM/filesystem.py +++ b/RomM/filesystem.py @@ -46,6 +46,11 @@ def __init__(self) -> None: base_path = os.path.abspath(os.path.join(os.getcwd(), "..", "..")) # Default to the ROMs directory, overridable via environment variable self._sd1_roms_storage_path = os.environ.get("ROMS_STORAGE_PATH", base_path) + # For non-MuOS/non-SpruceOS devices, use catalogue from environment or create one in the app directory + self._sd1_catalogue_path = os.environ.get( + "CATALOGUE_PATH", + os.path.join(os.getcwd(), "catalogue") + ) # Ensure the ROMs storage path exists if self._sd2_roms_storage_path and not os.path.exists( @@ -56,6 +61,15 @@ def __init__(self) -> None: except FileNotFoundError: print("Cannot create SD2 storage path", self._sd2_roms_storage_path) + # Ensure the catalogue path exists + if self._sd1_catalogue_path and not os.path.exists(self._sd1_catalogue_path): + try: + os.makedirs(self._sd1_catalogue_path, exist_ok=True) + print(f"Created catalogue directory: {self._sd1_catalogue_path}") + except Exception as e: + print(f"Cannot create catalogue directory {self._sd1_catalogue_path}: {e}") + self._sd1_catalogue_path = None + # Set the default SD card based on the existence of the storage path self._current_sd = int( os.getenv(