From 1604406e2b8b6e2edc6d559efafcefd9adddbc77 Mon Sep 17 00:00:00 2001 From: Marius Luca Date: Thu, 9 Oct 2025 16:50:25 +0300 Subject: [PATCH] - add a configurable ROMM_TMP_PATH environment variable for controlling where large file operations take place like 7z extraction --- backend/config/__init__.py | 1 + backend/utils/archive_7zip.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/config/__init__.py b/backend/config/__init__.py index efedee835..2d9f6cbc5 100644 --- a/backend/config/__init__.py +++ b/backend/config/__init__.py @@ -22,6 +22,7 @@ DEV_SQL_ECHO: Final = str_to_bool(os.environ.get("DEV_SQL_ECHO", "false")) # PATHS ROMM_BASE_PATH: Final = os.environ.get("ROMM_BASE_PATH", "/romm") +ROMM_TMP_PATH: Final = os.environ.get("ROMM_TMP_PATH", None) LIBRARY_BASE_PATH: Final = f"{ROMM_BASE_PATH}/library" RESOURCES_BASE_PATH: Final = f"{ROMM_BASE_PATH}/resources" ASSETS_BASE_PATH: Final = f"{ROMM_BASE_PATH}/assets" diff --git a/backend/utils/archive_7zip.py b/backend/utils/archive_7zip.py index 35f752da9..cc85539e0 100644 --- a/backend/utils/archive_7zip.py +++ b/backend/utils/archive_7zip.py @@ -7,6 +7,10 @@ from pathlib import Path from logger.logger import log +from config import ( + ROMM_TMP_PATH, +) + SEVEN_ZIP_PATH = "/usr/bin/7zz" FILE_READ_CHUNK_SIZE = 1024 * 8 @@ -60,7 +64,7 @@ def process_file_7z( if not largest_file: return False - with tempfile.TemporaryDirectory() as temp_dir: + with tempfile.TemporaryDirectory(dir = ROMM_TMP_PATH) as temp_dir: log.debug(f"Extracting {largest_file} from {file_path}...") temp_path = Path(temp_dir)