mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 14:56:01 +00:00
refactor: split HIGH_PRIO_STRUCTURE_PATH into STRUCTURE_PATH_A/B
Replace the single HIGH_PRIO_STRUCTURE_PATH config attribute with two glob patterns (STRUCTURE_PATH_A = roms/*, STRUCTURE_PATH_B = */roms) and update all call sites to detect Structure B via glob.glob, defaulting to Structure A when no match is found. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,7 +114,8 @@ class Config:
|
||||
ROMS_FOLDER_NAME: str
|
||||
FIRMWARE_FOLDER_NAME: str
|
||||
SKIP_HASH_CALCULATION: bool
|
||||
HIGH_PRIO_STRUCTURE_PATH: str
|
||||
STRUCTURE_PATH_A: str
|
||||
STRUCTURE_PATH_B: str
|
||||
EJS_DEBUG: bool
|
||||
EJS_CACHE_LIMIT: int | None
|
||||
EJS_DISABLE_AUTO_UNLOAD: bool
|
||||
@@ -133,7 +134,8 @@ class Config:
|
||||
|
||||
def __init__(self, **entries):
|
||||
self.__dict__.update(entries)
|
||||
self.HIGH_PRIO_STRUCTURE_PATH = f"{LIBRARY_BASE_PATH}/{self.ROMS_FOLDER_NAME}"
|
||||
self.STRUCTURE_PATH_A = f"{LIBRARY_BASE_PATH}/{self.ROMS_FOLDER_NAME}/*"
|
||||
self.STRUCTURE_PATH_B = f"{LIBRARY_BASE_PATH}/*/{self.ROMS_FOLDER_NAME}"
|
||||
|
||||
|
||||
class ConfigManager:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import binascii
|
||||
import glob
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
@@ -17,9 +18,9 @@ class FSFirmwareHandler(FSHandler):
|
||||
def get_firmware_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
return (
|
||||
f"{cnfg.FIRMWARE_FOLDER_NAME}/{fs_slug}"
|
||||
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
|
||||
else f"{fs_slug}/{cnfg.FIRMWARE_FOLDER_NAME}"
|
||||
f"{fs_slug}/{cnfg.FIRMWARE_FOLDER_NAME}"
|
||||
if glob.glob(cnfg.STRUCTURE_PATH_B)
|
||||
else f"{cnfg.FIRMWARE_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
|
||||
async def get_firmware(self, platform_fs_slug: str):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import glob
|
||||
import os
|
||||
|
||||
from anyio import Path as AnyioPath
|
||||
@@ -62,20 +63,16 @@ class FSPlatformsHandler(FSHandler):
|
||||
cnfg = cm.get_config()
|
||||
|
||||
# Fallback to config hint when detection is inconclusive
|
||||
return (
|
||||
cnfg.ROMS_FOLDER_NAME
|
||||
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
|
||||
else ""
|
||||
)
|
||||
return "" if glob.glob(cnfg.STRUCTURE_PATH_B) else cnfg.ROMS_FOLDER_NAME
|
||||
|
||||
def get_platform_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
|
||||
# Fallback to config hint when detection is inconclusive
|
||||
return (
|
||||
f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
|
||||
else f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
if glob.glob(cnfg.STRUCTURE_PATH_B)
|
||||
else f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
|
||||
async def add_platform(self, fs_slug: str) -> None:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import binascii
|
||||
import bz2
|
||||
import fnmatch
|
||||
import glob
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
@@ -313,9 +314,9 @@ class FSRomsHandler(FSHandler):
|
||||
def get_roms_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
return (
|
||||
f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
|
||||
else f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
if glob.glob(cnfg.STRUCTURE_PATH_B)
|
||||
else f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
|
||||
def parse_tags(self, fs_name: str) -> ParsedTags:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import enum
|
||||
import fnmatch
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
from collections.abc import Sequence
|
||||
@@ -49,7 +50,8 @@ sentry_sdk.init(
|
||||
)
|
||||
tracer = trace.get_tracer(__name__)
|
||||
|
||||
structure_level = 2 if os.path.exists(cm.get_config().HIGH_PRIO_STRUCTURE_PATH) else 1
|
||||
_cfg = cm.get_config()
|
||||
structure_level = 1 if glob.glob(_cfg.STRUCTURE_PATH_B) else 2
|
||||
|
||||
|
||||
@enum.unique
|
||||
|
||||
Reference in New Issue
Block a user