mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 02:24:09 +01:00
feat!: make filesystem.structure the single library layout
`filesystem.structure` now spells out the whole layout rather than only the part
below a platform folder. A template is relative to the library root, `{platform}`
marks the platform folder, and `{game}` marks where a game begins.
Merge `{gameFile}` and `{gameDir}` into one `{game}` terminal. The information a
terminal carried was the depth, not the kind: at a declared level a file is a
game of its own and a folder is one multi-file game, which a stat answers. That
drops the two-template idiom for a level holding both, and `_discover_default_roms`
with it, since the default scan is now just `roms/{platform}/{game}`.
Retire the auto-detected `{platform}/roms` layout, along with
`filesystem.roms_folder` and `filesystem.firmware_folder`, which named one path
segment each that a template now contains. Both are refused at startup with the
template that reproduces the layout, so an instance that relied on either says so
instead of scanning an empty library and marking every rom missing. Firmware gets
its own `structure.firmware` key rather than following the rom layout implicitly.
`get_roms_fs_structure` keeps meaning the folder a platform's games start in, so
the `.physical` sentinel paths already in the database still resolve. Per-platform
overrides have to agree with `default` on where the platform folder sits;
relocating one platform needs platform discovery and the watcher to union several
roots, which is left out.
The setup wizard reports `library_ready` plus the configured template instead of
a `struct_a`/`struct_b` discriminator, so the banner shows the layout in force
rather than guessing it client-side.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,20 +30,31 @@ from logger.formatter import BLUE
|
||||
from logger.formatter import highlight as hl
|
||||
from logger.logger import log
|
||||
|
||||
# Terminal macros for a custom library structure template. Exactly one must
|
||||
# appear, as the last path segment.
|
||||
STRUCTURE_GAME_FILE: Final = "gameFile"
|
||||
STRUCTURE_GAME_DIR: Final = "gameDir"
|
||||
# Macros that belong to Retrom's full-path templates but are resolved by RomM
|
||||
# itself (library base + roms folder + platform discovery). A per-platform
|
||||
# template is relative to the platform's ROM folder, so these are rejected with
|
||||
# a helpful message instead of being silently treated as wildcard levels.
|
||||
_STRUCTURE_RESERVED_NONTERMINAL: Final = frozenset({"platform", "library"})
|
||||
# Macros of a library structure template. `{platform}` is the platform folder and
|
||||
# `{game}` is the terminal, marking where the game itself begins.
|
||||
STRUCTURE_PLATFORM: Final = "platform"
|
||||
STRUCTURE_GAME: Final = "game"
|
||||
# Retrom spells the library root out; a RomM template is already relative to it.
|
||||
_STRUCTURE_RESERVED_ROOT: Final = "library"
|
||||
|
||||
# Keys of `filesystem.structure` that name a layout rather than a platform.
|
||||
STRUCTURE_DEFAULT_KEY: Final = "default"
|
||||
STRUCTURE_FIRMWARE_KEY: Final = "firmware"
|
||||
RESERVED_STRUCTURE_KEYS: Final = frozenset(
|
||||
{STRUCTURE_DEFAULT_KEY, STRUCTURE_FIRMWARE_KEY}
|
||||
)
|
||||
|
||||
STRUCTURE_DOCS_URL: Final = (
|
||||
"https://docs.romm.app/latest/getting-started/folder-structure/"
|
||||
)
|
||||
|
||||
DEFAULT_ROM_STRUCTURE: Final = "roms/{platform}/{game}"
|
||||
DEFAULT_FIRMWARE_STRUCTURE: Final = "bios/{platform}"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class StructureLevel:
|
||||
"""One intermediate directory level of a custom structure template.
|
||||
"""One directory level between a platform's folder and its games.
|
||||
|
||||
``literal`` is the exact folder name to match, or ``None`` for a wildcard
|
||||
macro level (``{region}``, ``{category}``, …) that matches any folder.
|
||||
@@ -54,100 +65,186 @@ class StructureLevel:
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class StructureTemplate:
|
||||
"""One parsed structure template for a platform.
|
||||
"""One parsed ROM layout, relative to the library root.
|
||||
|
||||
Relative to the platform's ROM folder: ``levels`` are the intermediate
|
||||
directory levels to descend (literal or wildcard), and ``each_file_is_game``
|
||||
selects the terminal: ``{gameFile}`` (each file is a ROM) vs ``{gameDir}``
|
||||
(each directory is a multi-file ROM).
|
||||
``platform_dir`` are the literal sections before the platform folder and
|
||||
``levels`` are the directory levels between that folder and the game.
|
||||
"""
|
||||
|
||||
platform_dir: tuple[str, ...]
|
||||
levels: tuple[StructureLevel, ...]
|
||||
each_file_is_game: bool
|
||||
|
||||
def platform_path(self, fs_slug: str) -> str:
|
||||
"""The platform's own folder, the root of everything it holds."""
|
||||
return "/".join((*self.platform_dir, fs_slug))
|
||||
|
||||
def games_dir(self, fs_slug: str) -> str:
|
||||
"""Where the platform's games start, as far as the template pins it down.
|
||||
|
||||
Stops at the first wildcard level, so with one present this is an
|
||||
ancestor of the games rather than the folder holding them.
|
||||
"""
|
||||
literals: list[str] = []
|
||||
for level in self.levels:
|
||||
if level.literal is None:
|
||||
break
|
||||
literals.append(level.literal)
|
||||
return "/".join((*self.platform_dir, fs_slug, *literals))
|
||||
|
||||
@property
|
||||
def has_wildcard_levels(self) -> bool:
|
||||
return any(level.literal is None for level in self.levels)
|
||||
|
||||
|
||||
def parse_structure_template(template: str) -> StructureTemplate:
|
||||
"""Parse one template string into the levels and terminal it describes.
|
||||
@dataclass(frozen=True)
|
||||
class FirmwareTemplate:
|
||||
"""One parsed firmware layout: literal sections around the platform folder."""
|
||||
|
||||
Template syntax mirrors Retrom: ``/``-separated path sections where a
|
||||
section wrapped in braces is a macro and a bare section is a literal folder
|
||||
name. The last section must be the terminal ``{gameFile}`` or ``{gameDir}``;
|
||||
every other braced section is a wildcard directory level. The template is
|
||||
relative to the platform's ROM folder, so ``{platform}`` / ``{library}`` are
|
||||
not used here.
|
||||
platform_dir: tuple[str, ...]
|
||||
subdir: tuple[str, ...]
|
||||
|
||||
def platform_path(self, fs_slug: str) -> str:
|
||||
return "/".join((*self.platform_dir, fs_slug, *self.subdir))
|
||||
|
||||
|
||||
def _template_sections(template: str) -> list[str]:
|
||||
sections = [section for section in template.split("/") if section != ""]
|
||||
if not sections:
|
||||
raise ValueError("template is empty")
|
||||
return sections
|
||||
|
||||
|
||||
def _macro_name(section: str) -> str | None:
|
||||
"""The macro inside a braced section, or ``None`` when it is a folder name."""
|
||||
if section.startswith("{") and section.endswith("}"):
|
||||
name = section[1:-1].strip()
|
||||
if not name:
|
||||
raise ValueError("empty macro '{}'")
|
||||
if name == _STRUCTURE_RESERVED_ROOT:
|
||||
raise ValueError(
|
||||
"'{library}' is not supported: a template is already relative to "
|
||||
"the library root"
|
||||
)
|
||||
return name
|
||||
if "{" in section or "}" in section:
|
||||
raise ValueError(f"malformed macro in section '{section}'")
|
||||
return None
|
||||
|
||||
|
||||
def _split_at_platform(
|
||||
sections: list[str], fs_slug: str | None
|
||||
) -> tuple[list[str], list[str]]:
|
||||
"""Split sections around the platform one, returning what precedes and follows.
|
||||
|
||||
The platform section is ``{platform}``, or the platform's own folder name when
|
||||
``fs_slug`` is given. Everything before it must be a literal folder name so
|
||||
that the folder to enumerate platforms in is a single known path.
|
||||
"""
|
||||
for index, section in enumerate(sections):
|
||||
name = _macro_name(section)
|
||||
is_platform = name == STRUCTURE_PLATFORM or (
|
||||
name is None and fs_slug is not None and section == fs_slug
|
||||
)
|
||||
if is_platform:
|
||||
before = sections[:index]
|
||||
for preceding in before:
|
||||
if _macro_name(preceding) is not None:
|
||||
raise ValueError(
|
||||
f"'{preceding}' cannot be a macro: every section before the "
|
||||
"platform folder must be a literal folder name"
|
||||
)
|
||||
return before, sections[index + 1 :]
|
||||
|
||||
if fs_slug is not None:
|
||||
raise ValueError(
|
||||
f"template must contain '{{platform}}' or the '{fs_slug}' folder name"
|
||||
)
|
||||
raise ValueError("template must contain '{platform}'")
|
||||
|
||||
|
||||
def parse_structure_template(
|
||||
template: str, fs_slug: str | None = None
|
||||
) -> StructureTemplate:
|
||||
"""Parse one ROM layout template into the platform folder and levels it describes.
|
||||
|
||||
Template syntax mirrors Retrom: a ``/``-separated path, relative to the
|
||||
library root, where a section wrapped in braces is a macro and a bare section
|
||||
is a literal folder name. ``{platform}`` marks the platform folder, the last
|
||||
section must be the terminal ``{game}``, and every other braced section is a
|
||||
wildcard directory level.
|
||||
|
||||
Args:
|
||||
fs_slug: The platform the template belongs to, which may name its folder
|
||||
literally instead of using ``{platform}``.
|
||||
|
||||
Raises ``ValueError`` on an invalid template.
|
||||
"""
|
||||
sections = [s for s in template.split("/") if s != ""]
|
||||
if not sections:
|
||||
raise ValueError("template is empty")
|
||||
sections = _template_sections(template)
|
||||
|
||||
if _macro_name(sections[-1]) != STRUCTURE_GAME:
|
||||
raise ValueError(
|
||||
"template must end with '{game}', marking where the game itself begins"
|
||||
)
|
||||
platform_dir, after = _split_at_platform(sections[:-1], fs_slug)
|
||||
|
||||
levels: list[StructureLevel] = []
|
||||
each_file_is_game: bool | None = None
|
||||
|
||||
for index, section in enumerate(sections):
|
||||
is_last = index == len(sections) - 1
|
||||
is_macro = section.startswith("{") and section.endswith("}")
|
||||
|
||||
if not is_macro:
|
||||
if "{" in section or "}" in section:
|
||||
raise ValueError(f"malformed macro in section '{section}'")
|
||||
levels.append(StructureLevel(literal=section))
|
||||
continue
|
||||
|
||||
name = section[1:-1].strip()
|
||||
if name in (STRUCTURE_GAME_FILE, STRUCTURE_GAME_DIR):
|
||||
if not is_last:
|
||||
raise ValueError(
|
||||
f"'{{{name}}}' must be the last path section of the template"
|
||||
)
|
||||
each_file_is_game = name == STRUCTURE_GAME_FILE
|
||||
continue
|
||||
|
||||
if name in _STRUCTURE_RESERVED_NONTERMINAL:
|
||||
raise ValueError(
|
||||
f"'{{{name}}}' is not supported: a platform template is relative "
|
||||
"to that platform's ROM folder (RomM resolves library root, roms "
|
||||
"folder and platform on its own)"
|
||||
)
|
||||
if not name:
|
||||
raise ValueError("empty macro '{}'")
|
||||
for section in after:
|
||||
name = _macro_name(section)
|
||||
if name in (STRUCTURE_PLATFORM, STRUCTURE_GAME):
|
||||
raise ValueError(f"'{{{name}}}' can only appear once")
|
||||
# Any other braced section is an organizational wildcard directory level.
|
||||
levels.append(StructureLevel(literal=None))
|
||||
levels.append(StructureLevel(literal=section if name is None else None))
|
||||
|
||||
if each_file_is_game is None:
|
||||
last = sections[-1]
|
||||
if last.startswith("{") and last.endswith("}"):
|
||||
# A near-miss on the terminal name (`{gameFolder}`) otherwise reads
|
||||
# as a wildcard level and reports only the missing terminal.
|
||||
return StructureTemplate(platform_dir=tuple(platform_dir), levels=tuple(levels))
|
||||
|
||||
|
||||
def parse_firmware_template(template: str) -> FirmwareTemplate:
|
||||
"""Parse the firmware layout template into the folder it points each platform at.
|
||||
|
||||
Firmware is a single folder per platform rather than a set of games, so the
|
||||
template takes ``{platform}`` surrounded by literal folder names, with no
|
||||
wildcard levels and no ``{game}`` terminal.
|
||||
|
||||
Raises ``ValueError`` on an invalid template.
|
||||
"""
|
||||
platform_dir, after = _split_at_platform(_template_sections(template), None)
|
||||
|
||||
for section in after:
|
||||
name = _macro_name(section)
|
||||
if name == STRUCTURE_GAME:
|
||||
raise ValueError(
|
||||
f"'{last}' is not a terminal: the template must end with "
|
||||
"'{gameFile}' (each file is a game) or '{gameDir}' (each "
|
||||
"directory is a game)"
|
||||
"'{game}' is not supported here: the firmware template points at a "
|
||||
"folder, not at games"
|
||||
)
|
||||
if name is not None:
|
||||
raise ValueError(
|
||||
f"'{section}' cannot be a macro: the firmware template takes literal "
|
||||
"folder names around '{platform}'"
|
||||
)
|
||||
raise ValueError("template must end with '{gameFile}' or '{gameDir}'")
|
||||
|
||||
return StructureTemplate(levels=tuple(levels), each_file_is_game=each_file_is_game)
|
||||
return FirmwareTemplate(platform_dir=tuple(platform_dir), subdir=tuple(after))
|
||||
|
||||
|
||||
def parse_platform_templates(
|
||||
value: str | list[str],
|
||||
value: str | list[str], fs_slug: str | None = None
|
||||
) -> tuple[StructureTemplate, ...]:
|
||||
"""Parse a platform's `filesystem.structure` value into its templates.
|
||||
|
||||
A platform may declare a single template (string) or several (list). The
|
||||
list form lets one platform mix layouts, e.g. loose games at the root plus
|
||||
games inside grouping subfolders::
|
||||
list form lets one platform mix layouts, e.g. games directly in the platform
|
||||
folder plus games inside grouping subfolders::
|
||||
|
||||
nes:
|
||||
- "{gameFile}"
|
||||
- "{category}/{gameFile}"
|
||||
- "roms/{platform}/{game}"
|
||||
- "roms/{platform}/{category}/{game}"
|
||||
|
||||
Discovery is the union of all listed templates. Raises ``ValueError`` if any
|
||||
template is invalid.
|
||||
"""
|
||||
templates = [value] if isinstance(value, str) else list(value)
|
||||
return tuple(parse_structure_template(template) for template in templates)
|
||||
return tuple(
|
||||
parse_structure_template(template, fs_slug=fs_slug) for template in templates
|
||||
)
|
||||
|
||||
|
||||
ROMM_USER_CONFIG_PATH: Final = f"{ROMM_BASE_PATH}/config"
|
||||
@@ -374,8 +471,6 @@ class Config:
|
||||
PEGASUS_AUTO_EXPORT_ON_SCAN: bool
|
||||
PLATFORMS_BINDING: dict[str, str]
|
||||
PLATFORMS_VERSIONS: dict[str, str]
|
||||
ROMS_FOLDER_NAME: str
|
||||
FIRMWARE_FOLDER_NAME: str
|
||||
STRUCTURE_TEMPLATES: dict[str, str | list[str]]
|
||||
SKIP_HASH_CALCULATION: bool
|
||||
SKIP_TITLE_ID_EXTRACTION: bool
|
||||
@@ -405,42 +500,52 @@ class Config:
|
||||
self.__dict__.update(entries)
|
||||
|
||||
@functools.cached_property
|
||||
def has_structure_path_a(self) -> bool:
|
||||
# Structure A ({roms_folder}/{platform}) takes priority: if the top-level roms
|
||||
# folder exists, claim Structure A even if some platform dirs happen to
|
||||
# contain a {roms_folder} sub-folder.
|
||||
roms_path = os.path.join(LIBRARY_BASE_PATH, self.ROMS_FOLDER_NAME)
|
||||
return os.path.isdir(roms_path)
|
||||
def default_structure_pattern(self) -> str:
|
||||
"""The raw `filesystem.structure.default` template, as configured."""
|
||||
return str(
|
||||
self.STRUCTURE_TEMPLATES.get(STRUCTURE_DEFAULT_KEY, DEFAULT_ROM_STRUCTURE)
|
||||
)
|
||||
|
||||
@functools.cached_property
|
||||
def has_structure_path_b(self) -> bool:
|
||||
if self.has_structure_path_a:
|
||||
return False
|
||||
def default_structure(self) -> StructureTemplate:
|
||||
"""The library-wide ROM layout, from `filesystem.structure.default`."""
|
||||
return parse_structure_template(self.default_structure_pattern)
|
||||
|
||||
pattern = os.path.join(
|
||||
LIBRARY_BASE_PATH, "*", glob.escape(self.ROMS_FOLDER_NAME)
|
||||
@functools.cached_property
|
||||
def firmware_structure(self) -> FirmwareTemplate:
|
||||
"""The firmware layout, from `filesystem.structure.firmware`."""
|
||||
return parse_firmware_template(
|
||||
str(
|
||||
self.STRUCTURE_TEMPLATES.get(
|
||||
STRUCTURE_FIRMWARE_KEY, DEFAULT_FIRMWARE_STRUCTURE
|
||||
)
|
||||
)
|
||||
)
|
||||
for match in glob.iglob(pattern):
|
||||
if os.path.isdir(match):
|
||||
return True
|
||||
|
||||
return False
|
||||
def platform_structure(self, fs_slug: str) -> tuple[StructureTemplate, ...]:
|
||||
"""The ROM layout(s) for a platform.
|
||||
|
||||
def platform_structure(self, fs_slug: str) -> tuple[StructureTemplate, ...] | None:
|
||||
"""The custom library structure(s) for a platform, or ``None``.
|
||||
|
||||
Opt-in per platform via `filesystem.structure` in config.yml (a map of
|
||||
``fs_slug -> template`` or ``fs_slug -> [template, ...]``, keyed
|
||||
case-insensitively like `system.platforms`). When unset,
|
||||
the platform uses RomM's default discovery (top-level files and
|
||||
folders). Returns the parsed structures whose discovery is unioned;
|
||||
templates are validated at load time, so parsing here is expected to
|
||||
succeed.
|
||||
Overridable per platform via `filesystem.structure` in config.yml (a map
|
||||
of ``fs_slug -> template`` or ``fs_slug -> [template, ...]``, keyed
|
||||
case-insensitively like `system.platforms`), which falls back to
|
||||
`filesystem.structure.default`. Returns the parsed layouts whose
|
||||
discovery is unioned; templates are validated at load time, so parsing
|
||||
here is expected to succeed.
|
||||
"""
|
||||
value = getattr(self, "STRUCTURE_TEMPLATES", {}).get(fs_slug.lower())
|
||||
key = fs_slug.lower()
|
||||
value = (
|
||||
None
|
||||
if key in RESERVED_STRUCTURE_KEYS
|
||||
else self.STRUCTURE_TEMPLATES.get(key)
|
||||
)
|
||||
if not value:
|
||||
return None
|
||||
return parse_platform_templates(value)
|
||||
return (self.default_structure,)
|
||||
return parse_platform_templates(value, fs_slug=key)
|
||||
|
||||
@functools.cached_property
|
||||
def platforms_dir(self) -> str:
|
||||
"""The library-relative folder the platform folders sit in."""
|
||||
return "/".join(self.default_structure.platform_dir)
|
||||
|
||||
|
||||
class ConfigManager:
|
||||
@@ -642,12 +747,6 @@ class ConfigManager:
|
||||
or {},
|
||||
PLATFORMS_VERSIONS=pydash.get(self._raw_config, "system.versions", {})
|
||||
or {},
|
||||
ROMS_FOLDER_NAME=pydash.get(
|
||||
self._raw_config, "filesystem.roms_folder", "roms"
|
||||
),
|
||||
FIRMWARE_FOLDER_NAME=pydash.get(
|
||||
self._raw_config, "filesystem.firmware_folder", "bios"
|
||||
),
|
||||
SKIP_HASH_CALCULATION=pydash.get(
|
||||
self._raw_config, "filesystem.skip_hash_calculation", False
|
||||
),
|
||||
@@ -827,8 +926,66 @@ class ConfigManager:
|
||||
|
||||
return normalized
|
||||
|
||||
def _check_retired_filesystem_keys(self) -> None:
|
||||
"""Exit if config.yml still sets a folder name `filesystem.structure` replaced.
|
||||
|
||||
Ignoring one would relocate the library under the user, so name the
|
||||
template that reproduces the layout instead.
|
||||
"""
|
||||
retired = {
|
||||
"filesystem.roms_folder": (
|
||||
STRUCTURE_DEFAULT_KEY,
|
||||
lambda folder: f"{folder}/{{platform}}/{{game}}",
|
||||
),
|
||||
"filesystem.firmware_folder": (
|
||||
STRUCTURE_FIRMWARE_KEY,
|
||||
lambda folder: f"{folder}/{{platform}}",
|
||||
),
|
||||
}
|
||||
for key, (structure_key, to_template) in retired.items():
|
||||
folder = pydash.get(self._raw_config, key)
|
||||
if folder is None:
|
||||
continue
|
||||
log.critical(
|
||||
f"Invalid config.yml: {key} is no longer supported. Replace it "
|
||||
f"with the equivalent layout:\n\n"
|
||||
f" filesystem:\n"
|
||||
f" structure:\n"
|
||||
f' {structure_key}: "{to_template(folder)}"\n\n'
|
||||
f"See {STRUCTURE_DOCS_URL}."
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
def check_library_layout(self) -> None:
|
||||
"""Exit if the library is laid out as `{platform}/roms` with no template.
|
||||
|
||||
The layout is opt-in rather than auto-detected, and scanning it as the
|
||||
default would mark every rom missing.
|
||||
"""
|
||||
if STRUCTURE_DEFAULT_KEY in self.config.STRUCTURE_TEMPLATES:
|
||||
return
|
||||
if os.path.isdir(os.path.join(LIBRARY_BASE_PATH, "roms")):
|
||||
return
|
||||
|
||||
pattern = os.path.join(LIBRARY_BASE_PATH, "*", "roms")
|
||||
if not any(os.path.isdir(match) for match in glob.iglob(pattern)):
|
||||
return
|
||||
|
||||
log.critical(
|
||||
"Detected a '{platform}/roms' library layout, which is no longer "
|
||||
"auto-detected. Declare it in config.yml:\n\n"
|
||||
" filesystem:\n"
|
||||
" structure:\n"
|
||||
' default: "{platform}/roms/{game}"\n'
|
||||
' firmware: "{platform}/bios"\n\n'
|
||||
f"See {STRUCTURE_DOCS_URL}."
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
def _validate_config(self):
|
||||
"""Validates the config.yml file"""
|
||||
self._check_retired_filesystem_keys()
|
||||
|
||||
if not isinstance(self.config.EXCLUDED_PLATFORMS, list):
|
||||
log.critical("Invalid config.yml: exclude.platforms must be a list")
|
||||
sys.exit(3)
|
||||
@@ -878,28 +1035,6 @@ class ConfigManager:
|
||||
self.config.PLATFORMS_VERSIONS, "system.versions"
|
||||
)
|
||||
|
||||
if not isinstance(self.config.ROMS_FOLDER_NAME, str):
|
||||
log.critical("Invalid config.yml: filesystem.roms_folder must be a string")
|
||||
sys.exit(3)
|
||||
|
||||
if self.config.ROMS_FOLDER_NAME == "":
|
||||
log.critical(
|
||||
"Invalid config.yml: filesystem.roms_folder cannot be an empty string"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
if not isinstance(self.config.FIRMWARE_FOLDER_NAME, str):
|
||||
log.critical(
|
||||
"Invalid config.yml: filesystem.firmware_folder must be a string"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
if self.config.FIRMWARE_FOLDER_NAME == "":
|
||||
log.critical(
|
||||
"Invalid config.yml: filesystem.firmware_folder cannot be an empty string"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
if not isinstance(self.config.EJS_DEBUG, bool):
|
||||
log.critical("Invalid config.yml: emulatorjs.debug must be a boolean")
|
||||
sys.exit(3)
|
||||
@@ -1037,28 +1172,58 @@ class ConfigManager:
|
||||
str(fs_slug).lower(): value
|
||||
for fs_slug, value in self.config.STRUCTURE_TEMPLATES.items()
|
||||
}
|
||||
for fs_slug, value in self.config.STRUCTURE_TEMPLATES.items():
|
||||
for key, value in self.config.STRUCTURE_TEMPLATES.items():
|
||||
is_str = isinstance(value, str)
|
||||
is_str_list = isinstance(value, list) and all(
|
||||
isinstance(t, str) for t in value
|
||||
)
|
||||
if not (is_str or is_str_list):
|
||||
log.critical(
|
||||
f"Invalid config.yml: filesystem.structure.{fs_slug} must be a "
|
||||
f"Invalid config.yml: filesystem.structure.{key} must be a "
|
||||
"template string or a list of template strings"
|
||||
)
|
||||
sys.exit(3)
|
||||
if key in RESERVED_STRUCTURE_KEYS and not is_str:
|
||||
log.critical(
|
||||
f"Invalid config.yml: filesystem.structure.{key} must be a "
|
||||
"single template string"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
templates: list[str] = [value] if isinstance(value, str) else value
|
||||
for template in templates:
|
||||
try:
|
||||
parse_structure_template(template)
|
||||
if key == STRUCTURE_FIRMWARE_KEY:
|
||||
parse_firmware_template(template)
|
||||
elif key == STRUCTURE_DEFAULT_KEY:
|
||||
parse_structure_template(template)
|
||||
else:
|
||||
parse_structure_template(template, fs_slug=key)
|
||||
except ValueError as exc:
|
||||
log.critical(
|
||||
f"Invalid config.yml: filesystem.structure.{fs_slug} "
|
||||
f"Invalid config.yml: filesystem.structure.{key} "
|
||||
f"('{template}'): {exc}"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
# A platform whose games live outside the folder platforms are enumerated
|
||||
# in would never be discovered, so require every override to agree with
|
||||
# `default` on where the platform folder itself sits.
|
||||
platform_dir = self.config.default_structure.platform_dir
|
||||
for key in self.config.STRUCTURE_TEMPLATES:
|
||||
if key in RESERVED_STRUCTURE_KEYS:
|
||||
continue
|
||||
for structure in self.config.platform_structure(key):
|
||||
if structure.platform_dir != platform_dir:
|
||||
log.critical(
|
||||
f"Invalid config.yml: filesystem.structure.{key} places the "
|
||||
f"'{key}' folder in "
|
||||
f"'{'/'.join(structure.platform_dir) or '.'}', but "
|
||||
f"filesystem.structure.default places platform folders in "
|
||||
f"'{'/'.join(platform_dir) or '.'}'"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
# Drop unknown media types rather than exiting, since a newer release
|
||||
# may ship sample configs referencing media types this version doesn't know.
|
||||
unknown_media = [
|
||||
@@ -1164,8 +1329,6 @@ class ConfigManager:
|
||||
},
|
||||
},
|
||||
"filesystem": {
|
||||
"roms_folder": self.config.ROMS_FOLDER_NAME,
|
||||
"firmware_folder": self.config.FIRMWARE_FOLDER_NAME,
|
||||
"structure": self.config.STRUCTURE_TEMPLATES,
|
||||
"skip_hash_calculation": self.config.SKIP_HASH_CALCULATION,
|
||||
"skip_title_id_extraction": self.config.SKIP_TITLE_ID_EXTRACTION,
|
||||
|
||||
@@ -36,7 +36,6 @@ from exceptions.fs_exceptions import PlatformAlreadyExistsException
|
||||
from handler.auth.constants import Scope
|
||||
from handler.database import db_stats_handler, db_user_handler
|
||||
from handler.filesystem import fs_platform_handler
|
||||
from handler.filesystem.base_handler import LibraryStructure
|
||||
from handler.metadata import (
|
||||
meta_csdb_handler,
|
||||
meta_demozoo_handler,
|
||||
@@ -266,7 +265,8 @@ async def get_setup_library_info(request: Request):
|
||||
Only accessible during initial setup (no admin users) or with authentication.
|
||||
|
||||
Returns:
|
||||
- detected_structure: "struct_a" (roms/{platform}), "struct_b" ({platform}/roms), or None
|
||||
- library_ready: whether the configured platforms folder exists on disk
|
||||
- library_structure: the configured `filesystem.structure.default` template
|
||||
- existing_platforms: list of objects with fs_slug and rom_count
|
||||
- supported_platforms: list of all supported platforms with metadata
|
||||
"""
|
||||
@@ -287,7 +287,7 @@ async def get_setup_library_info(request: Request):
|
||||
detail="Forbidden",
|
||||
)
|
||||
|
||||
detected_structure = fs_platform_handler.detect_library_structure()
|
||||
library_ready = fs_platform_handler.library_structure_exists()
|
||||
|
||||
# The per-platform rom counts below are a first-run hint, so a fresh
|
||||
# instance can show what RomM already sees on disk. Once the database
|
||||
@@ -295,7 +295,8 @@ async def get_setup_library_info(request: Request):
|
||||
# platform directory: tens of seconds on a large library.
|
||||
if db_stats_handler.get_roms_count() > 0:
|
||||
return {
|
||||
"detected_structure": detected_structure,
|
||||
"library_ready": library_ready,
|
||||
"library_structure": cm.get_config().default_structure_pattern,
|
||||
"existing_platforms": [],
|
||||
"supported_platforms": get_supported_platforms(),
|
||||
}
|
||||
@@ -309,20 +310,14 @@ async def get_setup_library_info(request: Request):
|
||||
|
||||
# Build existing platforms with rom counts
|
||||
existing_platforms = []
|
||||
if detected_structure and existing_platform_slugs:
|
||||
cnfg = cm.get_config()
|
||||
if library_ready and existing_platform_slugs:
|
||||
for fs_slug in existing_platform_slugs:
|
||||
rom_count = 0
|
||||
try:
|
||||
# Determine the roms directory based on structure
|
||||
if detected_structure == LibraryStructure.A:
|
||||
roms_path = os.path.join(
|
||||
LIBRARY_BASE_PATH, cnfg.ROMS_FOLDER_NAME, fs_slug
|
||||
)
|
||||
else: # Structure B
|
||||
roms_path = os.path.join(
|
||||
LIBRARY_BASE_PATH, fs_slug, cnfg.ROMS_FOLDER_NAME
|
||||
)
|
||||
roms_path = os.path.join(
|
||||
LIBRARY_BASE_PATH,
|
||||
fs_platform_handler.get_platform_fs_structure(fs_slug),
|
||||
)
|
||||
|
||||
# Count files and folders in the roms directory
|
||||
roms_dir = AnyioPath(roms_path)
|
||||
@@ -353,7 +348,8 @@ async def get_setup_library_info(request: Request):
|
||||
supported_platforms = get_supported_platforms()
|
||||
|
||||
return {
|
||||
"detected_structure": detected_structure,
|
||||
"library_ready": library_ready,
|
||||
"library_structure": cm.get_config().default_structure_pattern,
|
||||
"existing_platforms": existing_platforms,
|
||||
"supported_platforms": supported_platforms,
|
||||
}
|
||||
@@ -397,11 +393,7 @@ async def create_setup_platforms(request: Request, platform_slugs: list[str]):
|
||||
}
|
||||
|
||||
try:
|
||||
# Detect structure type to determine if we need to create the roms folder
|
||||
detected_structure = fs_platform_handler.detect_library_structure()
|
||||
|
||||
# If no structure detected, create structure A
|
||||
if detected_structure is None:
|
||||
if not fs_platform_handler.library_structure_exists():
|
||||
fs_platform_handler.create_library_structure()
|
||||
|
||||
# Create platform folders
|
||||
|
||||
@@ -36,11 +36,6 @@ UUID_V4_REGEX = re.compile(
|
||||
)
|
||||
|
||||
|
||||
class LibraryStructure(Enum):
|
||||
A = "struct_a"
|
||||
B = "struct_b"
|
||||
|
||||
|
||||
LANGUAGES = (
|
||||
("Ar", "Arabic"),
|
||||
("Da", "Danish"),
|
||||
|
||||
@@ -14,12 +14,8 @@ class FSFirmwareHandler(FSHandler):
|
||||
super().__init__(base_path=LIBRARY_BASE_PATH)
|
||||
|
||||
def get_firmware_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
return (
|
||||
f"{fs_slug}/{cnfg.FIRMWARE_FOLDER_NAME}"
|
||||
if cnfg.has_structure_path_b
|
||||
else f"{cnfg.FIRMWARE_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
"""The platform's firmware folder, relative to the library root."""
|
||||
return cm.get_config().firmware_structure.platform_path(fs_slug)
|
||||
|
||||
async def get_firmware(self, platform_fs_slug: str):
|
||||
"""Gets all filesystem firmware for a platform
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
from anyio import Path as AnyioPath
|
||||
|
||||
from config import LIBRARY_BASE_PATH
|
||||
from config.config_manager import config_manager as cm
|
||||
from exceptions.fs_exceptions import PlatformAlreadyExistsException
|
||||
from logger.logger import log
|
||||
|
||||
from .base_handler import FSHandler, LibraryStructure
|
||||
from .base_handler import FSHandler
|
||||
|
||||
|
||||
class FSPlatformsHandler(FSHandler):
|
||||
@@ -27,54 +25,24 @@ class FSPlatformsHandler(FSHandler):
|
||||
]
|
||||
|
||||
def create_library_structure(self) -> None:
|
||||
"""Creates the library structure with a roms folder."""
|
||||
cnfg = cm.get_config()
|
||||
roms_path = os.path.join(LIBRARY_BASE_PATH, cnfg.ROMS_FOLDER_NAME)
|
||||
os.makedirs(roms_path, exist_ok=True)
|
||||
"""Creates the folder the configured structure enumerates platforms in."""
|
||||
os.makedirs(
|
||||
os.path.join(LIBRARY_BASE_PATH, self.get_platforms_directory()),
|
||||
exist_ok=True,
|
||||
)
|
||||
|
||||
def detect_library_structure(self) -> LibraryStructure | None:
|
||||
"""Detects the library structure type.
|
||||
|
||||
Structure A ({roms_folder}/{platform}) takes priority over Structure B
|
||||
({platform}/{roms_folder}) so that existing libraries are not broken when a
|
||||
stray {platform}/{roms_folder} directory happens to exist alongside them.
|
||||
|
||||
Returns:
|
||||
"LibraryStructure.A" for Structure A (roms/{platform}) when the
|
||||
top-level roms folder exists.
|
||||
"LibraryStructure.B" for Structure B ({platform}/roms) when no
|
||||
top-level roms folder exists but at least one platform has a
|
||||
roms subfolder.
|
||||
None if no structure detected.
|
||||
"""
|
||||
cnfg = cm.get_config()
|
||||
|
||||
if cnfg.has_structure_path_a:
|
||||
return LibraryStructure.A
|
||||
|
||||
if cnfg.has_structure_path_b:
|
||||
return LibraryStructure.B
|
||||
|
||||
return None
|
||||
def library_structure_exists(self) -> bool:
|
||||
"""Whether the folder platforms are enumerated in is present on disk."""
|
||||
return os.path.isdir(
|
||||
os.path.join(LIBRARY_BASE_PATH, self.get_platforms_directory())
|
||||
)
|
||||
|
||||
def get_platforms_directory(self) -> str:
|
||||
cnfg = cm.get_config()
|
||||
|
||||
# Fallback to config hint when detection is inconclusive: default to
|
||||
# Structure A (roms/{platform}) so the bare library root is not treated
|
||||
# as a flat list of platforms. When the roms folder is missing entirely,
|
||||
# get_platforms() bootstraps it instead of failing.
|
||||
return "" if cnfg.has_structure_path_b else cnfg.ROMS_FOLDER_NAME
|
||||
return cm.get_config().platforms_dir
|
||||
|
||||
def get_platform_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
|
||||
# Fallback to config hint when detection is inconclusive
|
||||
return (
|
||||
f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
if cnfg.has_structure_path_b
|
||||
else f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
"""The folder a platform's games start in, relative to the library root."""
|
||||
return cm.get_config().default_structure.games_dir(fs_slug)
|
||||
|
||||
async def add_platform(self, fs_slug: str) -> None:
|
||||
"""Adds platform to the filesystem
|
||||
@@ -92,25 +60,17 @@ class FSPlatformsHandler(FSHandler):
|
||||
async def get_platforms(self) -> list[str]:
|
||||
"""Retrieves all platforms from the filesystem.
|
||||
|
||||
If no library structure exists yet (neither Structure A's top-level roms
|
||||
folder nor a Structure B {platform}/roms folder), defaults to Structure A
|
||||
by creating the roms folder and returns an empty list, so RomM starts
|
||||
cleanly with an empty library instead of failing.
|
||||
|
||||
Returns:
|
||||
List of platform slugs.
|
||||
"""
|
||||
cnfg = cm.get_config()
|
||||
|
||||
try:
|
||||
platforms = await self.list_directories(path=self.get_platforms_directory())
|
||||
except FileNotFoundError:
|
||||
# The platforms directory does not exist, which means no library
|
||||
# structure has been set up yet. Bootstrap Structure A so the
|
||||
# filesystem is in a valid state and report an empty library.
|
||||
# Bootstrap the configured folder so the filesystem is in a valid
|
||||
# state and report an empty library, rather than failing.
|
||||
log.warning(
|
||||
"No library structure found; creating default Structure A "
|
||||
"(roms folder) and starting with an empty library."
|
||||
"No library structure found; creating the configured platforms "
|
||||
"folder and starting with an empty library."
|
||||
)
|
||||
try:
|
||||
self.create_library_structure()
|
||||
@@ -122,24 +82,4 @@ class FSPlatformsHandler(FSHandler):
|
||||
# (e.g. Synology's #recycle) are never stat'ed
|
||||
platforms = self._exclude_platforms(platforms)
|
||||
|
||||
# For Structure B, only include directories that have a roms subfolder
|
||||
structure = self.detect_library_structure()
|
||||
if structure == LibraryStructure.B:
|
||||
filtered_platforms: list[str] = []
|
||||
for platform in platforms:
|
||||
roms_path = AnyioPath(
|
||||
os.path.join(LIBRARY_BASE_PATH, platform, cnfg.ROMS_FOLDER_NAME)
|
||||
)
|
||||
try:
|
||||
has_roms_folder = await roms_path.exists()
|
||||
except OSError:
|
||||
log.warning(
|
||||
f"Skipping unreadable library directory: {platform}",
|
||||
exc_info=True,
|
||||
)
|
||||
continue
|
||||
if has_roms_folder:
|
||||
filtered_platforms.append(platform)
|
||||
platforms = filtered_platforms
|
||||
|
||||
return platforms
|
||||
|
||||
@@ -112,7 +112,6 @@ class FSRom(TypedDict):
|
||||
fs_name: str
|
||||
fs_path: str
|
||||
flat: bool
|
||||
nested: bool
|
||||
files: list[RomFile]
|
||||
crc_hash: str
|
||||
md5_hash: str
|
||||
@@ -127,7 +126,6 @@ def build_empty_fs_rom(fs_name: str, fs_path: str, *, flat: bool) -> FSRom:
|
||||
fs_name=fs_name,
|
||||
fs_path=fs_path,
|
||||
flat=flat,
|
||||
nested=not flat,
|
||||
files=[],
|
||||
crc_hash="",
|
||||
md5_hash="",
|
||||
@@ -333,12 +331,8 @@ class FSRomsHandler(FSHandler):
|
||||
super().__init__(base_path=LIBRARY_BASE_PATH)
|
||||
|
||||
def get_roms_fs_structure(self, fs_slug: str) -> str:
|
||||
cnfg = cm.get_config()
|
||||
return (
|
||||
f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
|
||||
if cnfg.has_structure_path_b
|
||||
else f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
)
|
||||
"""The folder a platform's games start in, relative to the library root."""
|
||||
return cm.get_config().default_structure.games_dir(fs_slug)
|
||||
|
||||
def get_roms_upload_path(self, fs_slug: str) -> str:
|
||||
"""Where a newly uploaded rom file has to land to be discovered again.
|
||||
@@ -347,20 +341,10 @@ class FSRomsHandler(FSHandler):
|
||||
ValueError: when the platform's structure leaves the folder to the
|
||||
user, so no destination can be derived.
|
||||
"""
|
||||
rel_roms_path = self.get_roms_fs_structure(fs_slug)
|
||||
structures = cm.get_config().platform_structure(fs_slug)
|
||||
if structures is None:
|
||||
return rel_roms_path
|
||||
|
||||
for structure in structures:
|
||||
# A `{gameDir}` terminal makes each directory one multi-file rom, so
|
||||
# a loose file inside it is a rom file rather than a rom.
|
||||
if not structure.each_file_is_game:
|
||||
for structure in cm.get_config().platform_structure(fs_slug):
|
||||
if structure.has_wildcard_levels:
|
||||
continue
|
||||
literals = [level.literal for level in structure.levels]
|
||||
if any(literal is None for literal in literals):
|
||||
continue
|
||||
return "/".join([rel_roms_path, *(lit for lit in literals if lit)])
|
||||
return structure.games_dir(fs_slug)
|
||||
|
||||
raise ValueError(
|
||||
f"The custom library structure configured for {fs_slug} has no folder "
|
||||
@@ -1007,36 +991,18 @@ class FSRomsHandler(FSHandler):
|
||||
rom_sha1_h,
|
||||
)
|
||||
|
||||
async def _discover_default_roms(self, rel_roms_path: str) -> list[FSRom]:
|
||||
"""Default discovery: top-level files and folders of the roms path.
|
||||
|
||||
Each top-level file is a flat rom; each top-level directory is a single
|
||||
multi-file rom.
|
||||
"""
|
||||
fs_roms = [
|
||||
build_empty_fs_rom(rom, rel_roms_path, flat=True)
|
||||
for rom in self.exclude_single_files(await self.list_files(rel_roms_path))
|
||||
]
|
||||
fs_roms += [
|
||||
build_empty_fs_rom(rom, rel_roms_path, flat=False)
|
||||
for rom in self.exclude_multi_roms(
|
||||
await self.list_directories(rel_roms_path)
|
||||
)
|
||||
]
|
||||
return fs_roms
|
||||
|
||||
async def _discover_structured_roms(
|
||||
self, rel_roms_path: str, structure: StructureTemplate
|
||||
self, structure: StructureTemplate, fs_slug: str
|
||||
) -> list[FSRom]:
|
||||
"""Discover roms following a custom library structure template.
|
||||
"""Discover a platform's roms following one library structure template.
|
||||
|
||||
Descends the template's intermediate directory levels (literal names
|
||||
matched exactly, wildcard macros matching any folder), then collects
|
||||
roms at the terminal: ``{gameFile}`` makes each file a rom, ``{gameDir}``
|
||||
makes each directory a (multi-file) rom. Hidden (dot-prefixed) folders
|
||||
are never descended into or surfaced.
|
||||
matched exactly, wildcard macros matching any folder), then collects the
|
||||
games at the ``{game}`` terminal: each file there is a rom on its own and
|
||||
each directory is one multi-file rom. Hidden (dot-prefixed) folders are
|
||||
never descended into or surfaced.
|
||||
"""
|
||||
dirs = [rel_roms_path]
|
||||
dirs = [structure.platform_path(fs_slug)]
|
||||
for level in structure.levels:
|
||||
next_dirs: list[str] = []
|
||||
for directory in dirs:
|
||||
@@ -1055,51 +1021,48 @@ class FSRomsHandler(FSHandler):
|
||||
|
||||
fs_roms: list[FSRom] = []
|
||||
for directory in dirs:
|
||||
if structure.each_file_is_game:
|
||||
fs_roms += [
|
||||
build_empty_fs_rom(name, directory, flat=True)
|
||||
for name in self.exclude_single_files(
|
||||
await self.list_files(directory)
|
||||
)
|
||||
]
|
||||
else:
|
||||
fs_roms += [
|
||||
build_empty_fs_rom(name, directory, flat=False)
|
||||
for name in self.exclude_multi_roms(
|
||||
await self.list_directories(directory)
|
||||
)
|
||||
]
|
||||
fs_roms += [
|
||||
build_empty_fs_rom(name, directory, flat=True)
|
||||
for name in self.exclude_single_files(await self.list_files(directory))
|
||||
]
|
||||
fs_roms += [
|
||||
build_empty_fs_rom(name, directory, flat=False)
|
||||
for name in self.exclude_multi_roms(
|
||||
await self.list_directories(directory)
|
||||
)
|
||||
]
|
||||
return fs_roms
|
||||
|
||||
async def _collect_fs_roms(self, platform: Platform) -> list[FSRom]:
|
||||
"""Discover a platform's roms, honoring its custom structure if set.
|
||||
"""Discover a platform's roms following its library structure.
|
||||
|
||||
A platform may declare several structure templates (e.g. loose games at
|
||||
the root plus games inside grouping subfolders); discovery is their
|
||||
union, deduplicated by full path so overlapping templates don't surface
|
||||
a rom twice.
|
||||
A platform may declare several structure templates (e.g. games directly
|
||||
in the platform folder plus games inside grouping subfolders); discovery
|
||||
is their union, deduplicated by full path so overlapping templates don't
|
||||
surface a rom twice.
|
||||
"""
|
||||
rel_roms_path = self.get_roms_fs_structure(platform.fs_slug)
|
||||
structures = cm.get_config().platform_structure(platform.fs_slug)
|
||||
if structures is None:
|
||||
return await self._discover_default_roms(rel_roms_path)
|
||||
cnfg = cm.get_config()
|
||||
platform_path = cnfg.default_structure.platform_path(platform.fs_slug)
|
||||
structures = cnfg.platform_structure(platform.fs_slug)
|
||||
|
||||
fs_roms: list[FSRom] = []
|
||||
seen: set[tuple[str, str]] = set()
|
||||
for structure in structures:
|
||||
for rom in await self._discover_structured_roms(rel_roms_path, structure):
|
||||
for rom in await self._discover_structured_roms(
|
||||
structure, platform.fs_slug
|
||||
):
|
||||
key = (rom["fs_path"], rom["fs_name"])
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
fs_roms.append(rom)
|
||||
|
||||
# One template's `{gameDir}` can land on a folder another template
|
||||
# descends into (`{gameDir}` + `{category}/{gameFile}`). The folder is a
|
||||
# A folder one template reads as a multi-file game can be a level another
|
||||
# template descends through (`{game}` + `{category}/{game}`). It is a
|
||||
# grouping level there, so drop it rather than surface its contents twice.
|
||||
grouping: set[str] = set()
|
||||
for path in {rom["fs_path"] for rom in fs_roms}:
|
||||
while len(path) > len(rel_roms_path):
|
||||
while len(path) > len(platform_path):
|
||||
grouping.add(path)
|
||||
path = path.rsplit("/", 1)[0]
|
||||
|
||||
|
||||
@@ -1555,7 +1555,7 @@ async def scan_rom(
|
||||
extra=LOGGER_MODULE_NAME,
|
||||
)
|
||||
|
||||
if fs_rom["nested"]:
|
||||
if not fs_rom["flat"]:
|
||||
for file in fs_rom["files"]:
|
||||
log.info(
|
||||
f"\t · {hl(file.file_name, color=LIGHTYELLOW)}",
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# The test library is laid out with the platform folder first, which is no longer
|
||||
# the auto-detected default, so declare it.
|
||||
filesystem:
|
||||
structure:
|
||||
default: "{platform}/roms/{game}"
|
||||
firmware: "{platform}/bios"
|
||||
|
||||
@@ -9,6 +9,7 @@ from rq.job import Job
|
||||
from rq.utils import as_text
|
||||
|
||||
from config import ENABLE_SCHEDULED_CONVERT_IMAGES_TO_WEBP, SENTRY_DSN
|
||||
from config.config_manager import config_manager as cm
|
||||
from handler.database import db_save_handler
|
||||
from handler.metadata.base_handler import (
|
||||
MAME_XML_KEY,
|
||||
@@ -133,6 +134,8 @@ async def main() -> None:
|
||||
async with initialize_context():
|
||||
log.info("Running startup tasks")
|
||||
|
||||
cm.check_library_layout()
|
||||
|
||||
try:
|
||||
drop_stale_scheduled_scans()
|
||||
except Exception:
|
||||
|
||||
@@ -27,14 +27,14 @@ system:
|
||||
naomi: "arcade"
|
||||
|
||||
filesystem:
|
||||
roms_folder: "ROMS"
|
||||
firmware_folder: "BIOS"
|
||||
skip_hash_calculation: true
|
||||
structure:
|
||||
psx: "{category}/{gameDir}"
|
||||
default: "ROMS/{platform}/{game}"
|
||||
firmware: "BIOS/{platform}"
|
||||
psx: "ROMS/{platform}/{category}/{game}"
|
||||
nes:
|
||||
- "{gameFile}"
|
||||
- "{category}/{gameFile}"
|
||||
- "ROMS/{platform}/{game}"
|
||||
- "ROMS/{platform}/{category}/{game}"
|
||||
|
||||
scan:
|
||||
priority:
|
||||
|
||||
@@ -10,6 +10,7 @@ from config.config_manager import (
|
||||
DEFAULT_EXCLUDED_MULTI_FILE_DIRS,
|
||||
DEFAULT_EXCLUDED_PLATFORM_DIRS,
|
||||
ConfigManager,
|
||||
parse_firmware_template,
|
||||
parse_platform_templates,
|
||||
parse_structure_template,
|
||||
)
|
||||
@@ -53,8 +54,6 @@ def test_config_loader():
|
||||
)
|
||||
assert loader.config.PLATFORMS_BINDING == {"gc": "ngc"}
|
||||
assert loader.config.PLATFORMS_VERSIONS == {"naomi": "arcade"}
|
||||
assert loader.config.ROMS_FOLDER_NAME == "ROMS"
|
||||
assert loader.config.FIRMWARE_FOLDER_NAME == "BIOS"
|
||||
assert loader.config.SKIP_HASH_CALCULATION
|
||||
assert loader.config.EJS_DEBUG
|
||||
assert loader.config.EJS_DISABLE_AUTO_UNLOAD
|
||||
@@ -94,21 +93,29 @@ def test_config_loader():
|
||||
assert loader.config.GAMELIST_MEDIA_THUMBNAIL == "box3d"
|
||||
assert loader.config.GAMELIST_MEDIA_IMAGE == "title_screen"
|
||||
assert loader.config.STRUCTURE_TEMPLATES == {
|
||||
"psx": "{category}/{gameDir}",
|
||||
"nes": ["{gameFile}", "{category}/{gameFile}"],
|
||||
"default": "ROMS/{platform}/{game}",
|
||||
"firmware": "BIOS/{platform}",
|
||||
"psx": "ROMS/{platform}/{category}/{game}",
|
||||
"nes": ["ROMS/{platform}/{game}", "ROMS/{platform}/{category}/{game}"],
|
||||
}
|
||||
# The accessor parses templates on demand; unset platforms get None.
|
||||
assert loader.config.default_structure.platform_dir == ("ROMS",)
|
||||
assert loader.config.platforms_dir == "ROMS"
|
||||
assert loader.config.firmware_structure.platform_path("psx") == "BIOS/psx"
|
||||
|
||||
# The accessor parses templates on demand.
|
||||
psx = loader.config.platform_structure("psx")
|
||||
assert psx is not None and len(psx) == 1
|
||||
assert psx[0].each_file_is_game is False
|
||||
assert len(psx) == 1
|
||||
assert psx[0].platform_path("psx") == "ROMS/psx"
|
||||
assert len(psx[0].levels) == 1 and psx[0].levels[0].literal is None
|
||||
# The list form yields one structure per template (union on discovery).
|
||||
nes = loader.config.platform_structure("nes")
|
||||
assert nes is not None and len(nes) == 2
|
||||
assert nes[0].each_file_is_game is True and nes[0].levels == ()
|
||||
assert nes[1].each_file_is_game is True
|
||||
assert len(nes) == 2
|
||||
assert nes[0].levels == ()
|
||||
assert len(nes[1].levels) == 1 and nes[1].levels[0].literal is None
|
||||
assert loader.config.platform_structure("snes") is None
|
||||
# A platform without an override falls back to the library-wide layout.
|
||||
assert loader.config.platform_structure("snes") == (
|
||||
loader.config.default_structure,
|
||||
)
|
||||
|
||||
|
||||
def test_scan_priority_sources_match_metadata_source_enum():
|
||||
@@ -143,8 +150,8 @@ def test_empty_config_loader():
|
||||
assert loader.config.EXCLUDED_MULTI_PARTS_FILES == sorted(DEFAULT_EXCLUDED_FILES)
|
||||
assert loader.config.PLATFORMS_BINDING == {}
|
||||
assert loader.config.PLATFORMS_VERSIONS == {}
|
||||
assert loader.config.ROMS_FOLDER_NAME == "roms"
|
||||
assert loader.config.FIRMWARE_FOLDER_NAME == "bios"
|
||||
assert loader.config.platforms_dir == "roms"
|
||||
assert loader.config.firmware_structure.platform_path("nes") == "bios/nes"
|
||||
assert not loader.config.SKIP_HASH_CALCULATION
|
||||
assert not loader.config.EJS_DEBUG
|
||||
assert loader.config.EJS_CACHE_LIMIT is None
|
||||
@@ -163,33 +170,48 @@ def test_empty_config_loader():
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("template", "levels", "each_file_is_game"),
|
||||
("template", "platform_dir", "levels"),
|
||||
[
|
||||
("{gameFile}", (), True),
|
||||
("{gameDir}", (), False),
|
||||
("{category}/{gameFile}", (None,), True),
|
||||
("Hacks/{gameFile}", ("Hacks",), True),
|
||||
("{region}/{system}/{gameDir}", (None, None), False),
|
||||
("roms/{region}/{gameFile}", ("roms", None), True),
|
||||
("{platform}/{game}", (), ()),
|
||||
("roms/{platform}/{game}", ("roms",), ()),
|
||||
("roms/{platform}/{category}/{game}", ("roms",), (None,)),
|
||||
("roms/{platform}/Hacks/{game}", ("roms",), ("Hacks",)),
|
||||
(
|
||||
"games/all/{platform}/{region}/{system}/{game}",
|
||||
("games", "all"),
|
||||
(None, None),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parse_structure_template_valid(template, levels, each_file_is_game):
|
||||
def test_parse_structure_template_valid(template, platform_dir, levels):
|
||||
structure = parse_structure_template(template)
|
||||
assert structure.each_file_is_game is each_file_is_game
|
||||
assert structure.platform_dir == platform_dir
|
||||
assert tuple(level.literal for level in structure.levels) == levels
|
||||
|
||||
|
||||
def test_parse_structure_template_accepts_the_platform_folder_by_name():
|
||||
"""A per-platform override may name the folder outright instead of using the
|
||||
macro, which is how the key already reads."""
|
||||
structure = parse_structure_template("roms/ps3/{category}/{game}", fs_slug="ps3")
|
||||
assert structure.platform_dir == ("roms",)
|
||||
assert structure.platform_path("ps3") == "roms/ps3"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"template",
|
||||
[
|
||||
"",
|
||||
"justliteral",
|
||||
"{category}", # no terminal
|
||||
"{gameFile}/{gameDir}", # terminal not last
|
||||
"{gameDir}/extra", # terminal not last
|
||||
"{platform}/{gameFile}", # reserved macro RomM resolves itself
|
||||
"{library}/{gameFile}",
|
||||
"{}/{gameFile}", # empty macro
|
||||
"roms/{platform}", # no terminal
|
||||
"roms/{platform}/{category}", # no terminal
|
||||
"roms/{game}", # no platform folder
|
||||
"{game}/roms/{platform}", # terminal not last
|
||||
"roms/{platform}/{game}/extra", # terminal not last
|
||||
"roms/{platform}/{platform}/{game}", # platform folder twice
|
||||
"{category}/{platform}/{game}", # wildcard above the platform folder
|
||||
"{library}/roms/{platform}/{game}", # macro RomM resolves itself
|
||||
"roms/{platform}/{}/{game}", # empty macro
|
||||
"roms/{platform}/{gameFile}", # the terminal is spelled {game}
|
||||
],
|
||||
)
|
||||
def test_parse_structure_template_invalid(template):
|
||||
@@ -197,11 +219,32 @@ def test_parse_structure_template_invalid(template):
|
||||
parse_structure_template(template)
|
||||
|
||||
|
||||
def test_parse_structure_template_names_a_near_miss_terminal():
|
||||
"""`{gameFolder}` is an easy slip for `{gameDir}`, so the error has to point
|
||||
at it rather than only report a missing terminal."""
|
||||
with pytest.raises(ValueError, match=r"\{gameFolder\}.*is not a terminal"):
|
||||
parse_structure_template("{category}/{gameFolder}")
|
||||
@pytest.mark.parametrize(
|
||||
("template", "platform_dir", "subdir"),
|
||||
[
|
||||
("bios/{platform}", ("bios",), ()),
|
||||
("{platform}/bios", (), ("bios",)),
|
||||
("{platform}/firmware/bios", (), ("firmware", "bios")),
|
||||
],
|
||||
)
|
||||
def test_parse_firmware_template_valid(template, platform_dir, subdir):
|
||||
template_parsed = parse_firmware_template(template)
|
||||
assert template_parsed.platform_dir == platform_dir
|
||||
assert template_parsed.subdir == subdir
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"template",
|
||||
[
|
||||
"",
|
||||
"bios", # no platform folder
|
||||
"bios/{platform}/{game}", # firmware is a folder, not a set of games
|
||||
"bios/{platform}/{region}", # no wildcard levels
|
||||
],
|
||||
)
|
||||
def test_parse_firmware_template_invalid(template):
|
||||
with pytest.raises(ValueError):
|
||||
parse_firmware_template(template)
|
||||
|
||||
|
||||
def test_structure_templates_are_keyed_case_insensitively(monkeypatch, tmp_path):
|
||||
@@ -209,29 +252,34 @@ def test_structure_templates_are_keyed_case_insensitively(monkeypatch, tmp_path)
|
||||
has to as well or the same key works in one block and not the other."""
|
||||
config_file = tmp_path / "config.yml"
|
||||
config_file.write_text(
|
||||
"filesystem:\n structure:\n 'Atari - 2600': '{gameFile}'\n"
|
||||
"filesystem:\n structure:\n"
|
||||
" 'Atari - 2600': 'roms/{platform}/Hacks/{game}'\n"
|
||||
)
|
||||
config = ConfigManager(str(config_file)).get_config()
|
||||
|
||||
assert config.platform_structure("Atari - 2600") is not None
|
||||
assert config.platform_structure("atari - 2600") is not None
|
||||
for key in ("Atari - 2600", "atari - 2600"):
|
||||
structure = config.platform_structure(key)
|
||||
assert len(structure) == 1
|
||||
assert structure[0].levels[0].literal == "Hacks"
|
||||
|
||||
|
||||
def test_parse_platform_templates_string_and_list():
|
||||
# A bare string yields a single structure.
|
||||
single = parse_platform_templates("{gameFile}")
|
||||
assert len(single) == 1 and single[0].each_file_is_game is True
|
||||
single = parse_platform_templates("roms/{platform}/{game}")
|
||||
assert len(single) == 1 and single[0].levels == ()
|
||||
|
||||
# A list yields one structure per template, preserving order.
|
||||
multi = parse_platform_templates(["{gameFile}", "{category}/{gameDir}"])
|
||||
multi = parse_platform_templates(
|
||||
["roms/{platform}/{game}", "roms/{platform}/{category}/{game}"]
|
||||
)
|
||||
assert len(multi) == 2
|
||||
assert multi[0].levels == () and multi[0].each_file_is_game is True
|
||||
assert len(multi[1].levels) == 1 and multi[1].each_file_is_game is False
|
||||
assert multi[0].levels == ()
|
||||
assert len(multi[1].levels) == 1 and multi[1].levels[0].literal is None
|
||||
|
||||
|
||||
def test_parse_platform_templates_propagates_invalid():
|
||||
with pytest.raises(ValueError):
|
||||
parse_platform_templates(["{gameFile}", "nope"])
|
||||
parse_platform_templates(["roms/{platform}/{game}", "nope"])
|
||||
|
||||
|
||||
def test_missing_config_file_is_created(tmp_path):
|
||||
@@ -290,8 +338,8 @@ def test_malformed_yaml_falls_back_to_defaults():
|
||||
)
|
||||
)
|
||||
|
||||
assert loader.config.ROMS_FOLDER_NAME == "roms"
|
||||
assert loader.config.FIRMWARE_FOLDER_NAME == "bios"
|
||||
assert loader.config.platforms_dir == "roms"
|
||||
assert loader.config.firmware_structure.platform_path("nes") == "bios/nes"
|
||||
assert loader.config.SCAN_MEDIA == ["box2d", "screenshot", "manual"]
|
||||
# The parse error is surfaced so the UI can warn the user their whole
|
||||
# config (not just the broken part) was discarded.
|
||||
@@ -571,3 +619,110 @@ def test_platform_binding_lookup_ignores_case(tmp_path):
|
||||
|
||||
loader.remove_platform_binding("GAMECUBE")
|
||||
assert loader.config.PLATFORMS_BINDING == {}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def critical(mocker):
|
||||
"""The last message the config manager logged before exiting."""
|
||||
spy = mocker.patch("config.config_manager.log.critical")
|
||||
return lambda: str(spy.call_args[0][0])
|
||||
|
||||
|
||||
def _write_filesystem_config(tmp_path: Path, block: str) -> ConfigManager:
|
||||
config_file = tmp_path / "config.yml"
|
||||
config_file.write_text(f"filesystem:\n{block}")
|
||||
return ConfigManager(str(config_file))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("key", "folder", "expected"),
|
||||
[
|
||||
("roms_folder", "retro_games", 'default: "retro_games/{platform}/{game}"'),
|
||||
("firmware_folder", "fw", 'firmware: "fw/{platform}"'),
|
||||
],
|
||||
)
|
||||
def test_retired_folder_keys_exit_with_the_replacement(
|
||||
tmp_path, key, folder, expected, critical
|
||||
):
|
||||
"""Ignoring them would silently relocate the library, so refuse to start and
|
||||
name the template that reproduces the layout."""
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
_write_filesystem_config(tmp_path, f" {key}: {folder}\n")
|
||||
|
||||
assert excinfo.value.code == 3
|
||||
assert expected in critical()
|
||||
|
||||
|
||||
def test_an_override_may_not_move_the_platform_folder(tmp_path, critical):
|
||||
"""A platform outside the folder platforms are enumerated in would never be
|
||||
discovered."""
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
_write_filesystem_config(
|
||||
tmp_path,
|
||||
" structure:\n"
|
||||
' default: "roms/{platform}/{game}"\n'
|
||||
' ps3: "disc-games/{platform}/{game}"\n',
|
||||
)
|
||||
|
||||
assert excinfo.value.code == 3
|
||||
assert "disc-games" in critical()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", ["default", "firmware"])
|
||||
def test_a_reserved_structure_key_takes_a_single_template(tmp_path, key):
|
||||
"""Only a platform can union several layouts; the library has just one."""
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
_write_filesystem_config(
|
||||
tmp_path,
|
||||
f' structure:\n {key}:\n - "roms/{{platform}}/{{game}}"\n',
|
||||
)
|
||||
|
||||
assert excinfo.value.code == 3
|
||||
|
||||
|
||||
def test_an_invalid_firmware_template_is_rejected(tmp_path):
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
_write_filesystem_config(
|
||||
tmp_path, ' structure:\n firmware: "bios/{platform}/{game}"\n'
|
||||
)
|
||||
|
||||
assert excinfo.value.code == 3
|
||||
|
||||
|
||||
def test_the_retired_library_layout_check_names_the_template(
|
||||
tmp_path, mocker, critical
|
||||
):
|
||||
"""A `{platform}/roms` library used to be auto-detected; now it has to say so
|
||||
rather than scan as empty and mark every rom missing."""
|
||||
library = tmp_path / "library"
|
||||
(library / "n64" / "roms").mkdir(parents=True)
|
||||
mocker.patch("config.config_manager.LIBRARY_BASE_PATH", str(library))
|
||||
|
||||
loader = _write_filesystem_config(tmp_path, " skip_hash_calculation: false\n")
|
||||
with pytest.raises(SystemExit) as excinfo:
|
||||
loader.check_library_layout()
|
||||
|
||||
assert excinfo.value.code == 3
|
||||
assert 'default: "{platform}/roms/{game}"' in critical()
|
||||
|
||||
|
||||
def test_the_retired_library_layout_check_passes_once_declared(tmp_path, mocker):
|
||||
library = tmp_path / "library"
|
||||
(library / "n64" / "roms").mkdir(parents=True)
|
||||
mocker.patch("config.config_manager.LIBRARY_BASE_PATH", str(library))
|
||||
|
||||
loader = _write_filesystem_config(
|
||||
tmp_path, ' structure:\n default: "{platform}/roms/{game}"\n'
|
||||
)
|
||||
loader.check_library_layout()
|
||||
|
||||
|
||||
def test_a_platform_named_like_a_layout_key_uses_the_default(tmp_path):
|
||||
"""`structure.firmware` is a firmware folder, not a template for a platform
|
||||
whose folder happens to be called `firmware`."""
|
||||
loader = _write_filesystem_config(
|
||||
tmp_path, ' structure:\n firmware: "bios/{platform}"\n'
|
||||
)
|
||||
|
||||
config = loader.get_config()
|
||||
assert config.platform_structure("firmware") == (config.default_structure,)
|
||||
|
||||
@@ -725,7 +725,6 @@ class TestIdentifyRomTagReparse:
|
||||
"fs_name": "Game (USA) (En) (Proto) (v1.1) (Rev A).zip",
|
||||
"fs_path": "test/roms",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -921,7 +920,6 @@ def make_fs_rom(fs_name: str, fs_path: str = "test/roms") -> FSRom:
|
||||
"fs_name": fs_name,
|
||||
"fs_path": fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -1202,7 +1200,6 @@ class TestIdentifyPlatformMarksMissingBeforeScan:
|
||||
"fs_name": "New Name.zip",
|
||||
"fs_path": "test/roms",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -1284,7 +1281,6 @@ class TestIdentifyPlatformEmitsRestoredRoms:
|
||||
"fs_name": "Game.zip",
|
||||
"fs_path": "test/roms",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -1738,7 +1734,9 @@ class TestScanSelectedRoms:
|
||||
identify.assert_not_called()
|
||||
db_rom.update_rom.assert_called_once_with(rom.id, {"missing_from_fs": True})
|
||||
|
||||
async def test_a_multi_file_rom_is_reported_as_nested(self, mocker, platform, rom):
|
||||
async def test_a_multi_file_rom_is_reported_as_not_flat(
|
||||
self, mocker, platform, rom
|
||||
):
|
||||
mocker.patch.object(
|
||||
scan_module, "redis_client", Mock(get=Mock(return_value=None))
|
||||
)
|
||||
@@ -1769,7 +1767,7 @@ class TestScanSelectedRoms:
|
||||
)
|
||||
|
||||
fs_rom = identify.call_args.kwargs["fs_rom"]
|
||||
assert fs_rom["nested"] is True
|
||||
assert fs_rom["flat"] is False
|
||||
assert fs_rom["flat"] is False
|
||||
|
||||
async def test_a_scan_stopped_mid_flight_raises(self, mocker, platform, rom):
|
||||
@@ -2539,7 +2537,6 @@ def identify_harness(mocker):
|
||||
"fs_name": "Game",
|
||||
"fs_path": "test/roms",
|
||||
"flat": False,
|
||||
"nested": True,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -2686,7 +2683,6 @@ class TestIdentifyPlatformLoadsFilesForQuickScan:
|
||||
"fs_name": "Game",
|
||||
"fs_path": "test/roms",
|
||||
"flat": False,
|
||||
"nested": True,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
|
||||
@@ -156,12 +156,12 @@ def test_heartbeat_metadata_unknown_source_is_not_rate_limited(client):
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
|
||||
|
||||
def test_get_setup_library_info_structure_a_detected(client, access_token):
|
||||
"""Test get_setup_library_info with Structure A detected"""
|
||||
def test_get_setup_library_info_reports_a_ready_library(client, access_token):
|
||||
"""Test get_setup_library_info with the platforms folder present"""
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
@@ -207,7 +207,7 @@ def test_get_setup_library_info_structure_a_detected(client, access_token):
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
data = response.json()
|
||||
|
||||
assert data["detected_structure"] == "struct_a"
|
||||
assert data["library_ready"] is True
|
||||
assert len(data["existing_platforms"]) == 2
|
||||
assert data["existing_platforms"][0]["fs_slug"] == "n64"
|
||||
assert data["existing_platforms"][0]["rom_count"] == 2
|
||||
@@ -216,12 +216,12 @@ def test_get_setup_library_info_structure_a_detected(client, access_token):
|
||||
assert "supported_platforms" in data
|
||||
|
||||
|
||||
def test_get_setup_library_info_structure_b_detected(client, admin_user, access_token):
|
||||
"""Test get_setup_library_info with Structure B detected"""
|
||||
def test_get_setup_library_info_counts_one_platform(client, admin_user, access_token):
|
||||
"""Test get_setup_library_info reports a single platform's rom count"""
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "B"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
@@ -255,18 +255,18 @@ def test_get_setup_library_info_structure_b_detected(client, admin_user, access_
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
data = response.json()
|
||||
|
||||
assert data["detected_structure"] == "B"
|
||||
assert data["library_ready"] is True
|
||||
assert len(data["existing_platforms"]) == 1
|
||||
assert data["existing_platforms"][0]["fs_slug"] == "gba"
|
||||
assert data["existing_platforms"][0]["rom_count"] == 3
|
||||
|
||||
|
||||
def test_get_setup_library_info_no_structure_detected(client, admin_user, access_token):
|
||||
"""Test get_setup_library_info when no structure is detected"""
|
||||
def test_get_setup_library_info_no_library_yet(client, admin_user, access_token):
|
||||
"""Test get_setup_library_info when the platforms folder is absent"""
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = None
|
||||
mock_detect.return_value = False
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
@@ -281,7 +281,7 @@ def test_get_setup_library_info_no_structure_detected(client, admin_user, access
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
data = response.json()
|
||||
|
||||
assert data["detected_structure"] is None
|
||||
assert data["library_ready"] is False
|
||||
assert data["existing_platforms"] == []
|
||||
assert "supported_platforms" in data
|
||||
|
||||
@@ -289,9 +289,9 @@ def test_get_setup_library_info_no_structure_detected(client, admin_user, access
|
||||
def test_get_setup_library_info_handles_errors(client, admin_user, access_token):
|
||||
"""Test get_setup_library_info handles filesystem errors gracefully"""
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
@@ -317,13 +317,13 @@ def test_get_setup_library_info_skips_filesystem_walk_when_roms_exist(
|
||||
"""A library with scanned ROMs never needs the on-disk hint, so skip the walk."""
|
||||
with (
|
||||
patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect,
|
||||
patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
) as mock_get_platforms,
|
||||
):
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
mock_get_platforms.return_value = ["n64"]
|
||||
|
||||
response = client.get(
|
||||
@@ -334,7 +334,7 @@ def test_get_setup_library_info_skips_filesystem_walk_when_roms_exist(
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
data = response.json()
|
||||
|
||||
assert data["detected_structure"] == "struct_a"
|
||||
assert data["library_ready"] is True
|
||||
assert data["existing_platforms"] == []
|
||||
assert len(data["supported_platforms"]) > 0
|
||||
mock_get_platforms.assert_not_called()
|
||||
@@ -346,14 +346,14 @@ def test_get_setup_library_info_walks_when_platforms_have_no_roms(
|
||||
"""Platform rows without ROMs still need the hint: that is the case it exists for."""
|
||||
with (
|
||||
patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect,
|
||||
patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.get_platforms"
|
||||
) as mock_get_platforms,
|
||||
patch("endpoints.heartbeat.AnyioPath") as mock_anyio_path,
|
||||
):
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
mock_get_platforms.return_value = ["n64"]
|
||||
|
||||
async def mock_iterdir():
|
||||
@@ -382,9 +382,9 @@ def test_create_setup_platforms_success(client, admin_user, access_token):
|
||||
platform_slugs = ["n64", "psx", "gba"]
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.add_platform"
|
||||
@@ -422,14 +422,14 @@ def test_create_setup_platforms_empty_list(client, admin_user, access_token):
|
||||
assert data["message"] == "No platforms selected"
|
||||
|
||||
|
||||
def test_create_setup_platforms_creates_structure_a_when_none_exists(
|
||||
def test_create_setup_platforms_creates_the_library_when_absent(
|
||||
client, admin_user, access_token
|
||||
):
|
||||
"""Test create_setup_platforms creates Structure A when no structure detected"""
|
||||
platform_slugs = ["n64"]
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = None # No structure detected
|
||||
|
||||
@@ -442,9 +442,9 @@ def test_create_setup_platforms_creates_structure_a_when_none_exists(
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
# Should create roms folder first
|
||||
# The test config puts platform folders at the library root.
|
||||
mock_makedirs.assert_called_once()
|
||||
assert "roms" in str(mock_makedirs.call_args[0][0])
|
||||
assert str(mock_makedirs.call_args[0][0]).endswith("library/")
|
||||
|
||||
|
||||
def test_create_setup_platforms_skips_existing_platforms(
|
||||
@@ -454,9 +454,9 @@ def test_create_setup_platforms_skips_existing_platforms(
|
||||
platform_slugs = ["n64", "psx", "gba"]
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.add_platform"
|
||||
@@ -489,9 +489,9 @@ def test_create_setup_platforms_handles_permission_errors(
|
||||
platform_slugs = ["n64"]
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.detect_library_structure"
|
||||
"endpoints.heartbeat.fs_platform_handler.library_structure_exists"
|
||||
) as mock_detect:
|
||||
mock_detect.return_value = "struct_a"
|
||||
mock_detect.return_value = True
|
||||
|
||||
with patch(
|
||||
"endpoints.heartbeat.fs_platform_handler.add_platform"
|
||||
|
||||
@@ -30,8 +30,10 @@ class TestFSFirmwareHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
|
||||
def test_init_uses_library_base_path(self, handler: FSFirmwareHandler):
|
||||
@@ -138,31 +140,23 @@ class TestFSFirmwareHandler:
|
||||
assert hasattr(handler, "stream_file")
|
||||
assert hasattr(handler, "exclude_single_files")
|
||||
|
||||
def test_firmware_path_construction_structure_a(
|
||||
def test_firmware_path_follows_the_configured_template(
|
||||
self, handler: FSFirmwareHandler, config
|
||||
):
|
||||
"""Test that firmware paths are constructed correctly for Structure A"""
|
||||
platform_fs_slug = "n64"
|
||||
config.has_structure_path_b = False
|
||||
with patch(
|
||||
"handler.filesystem.firmware_handler.cm.get_config", return_value=config
|
||||
):
|
||||
assert handler.get_firmware_fs_structure("n64") == "n64/bios"
|
||||
|
||||
def test_firmware_path_can_lead_with_the_firmware_folder(
|
||||
self, handler: FSFirmwareHandler
|
||||
):
|
||||
config = Config(STRUCTURE_TEMPLATES={"firmware": "bios/{platform}"})
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.firmware_handler.cm.get_config", return_value=config
|
||||
):
|
||||
path = handler.get_firmware_fs_structure(platform_fs_slug)
|
||||
assert path == f"{config.FIRMWARE_FOLDER_NAME}/{platform_fs_slug}"
|
||||
|
||||
def test_firmware_path_construction_structure_b(
|
||||
self, handler: FSFirmwareHandler, config
|
||||
):
|
||||
"""Test that firmware paths are constructed correctly for Structure B"""
|
||||
platform_fs_slug = "n64"
|
||||
config.has_structure_path_b = True
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.firmware_handler.cm.get_config", return_value=config
|
||||
):
|
||||
path = handler.get_firmware_fs_structure(platform_fs_slug)
|
||||
assert path == f"{platform_fs_slug}/{config.FIRMWARE_FOLDER_NAME}"
|
||||
assert handler.get_firmware_fs_structure("n64") == "bios/n64"
|
||||
|
||||
async def test_multiple_platform_handling(self, handler: FSFirmwareHandler, config):
|
||||
"""Test handling of different platform slugs"""
|
||||
@@ -174,7 +168,7 @@ class TestFSFirmwareHandler:
|
||||
for platform in platforms:
|
||||
path = handler.get_firmware_fs_structure(platform)
|
||||
assert platform in path
|
||||
assert config.FIRMWARE_FOLDER_NAME in path
|
||||
assert "bios" in path
|
||||
|
||||
# Test that we can actually get firmware for existing platforms
|
||||
firmware_files = await handler.get_firmware(platform)
|
||||
|
||||
@@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from config.config_manager import LIBRARY_BASE_PATH, Config
|
||||
from handler.filesystem.platforms_handler import FSPlatformsHandler, LibraryStructure
|
||||
from handler.filesystem.platforms_handler import FSPlatformsHandler
|
||||
|
||||
|
||||
class TestFSPlatformsHandler:
|
||||
@@ -25,8 +25,7 @@ class TestFSPlatformsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={},
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
@@ -40,8 +39,22 @@ class TestFSPlatformsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="ROMS",
|
||||
FIRMWARE_FOLDER_NAME="BIOS",
|
||||
STRUCTURE_TEMPLATES={"default": "ROMS/{platform}/{game}"},
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def config_platform_first(self):
|
||||
"""A `{platform}/roms` layout, which is now opt-in via a template."""
|
||||
return Config(
|
||||
EXCLUDED_PLATFORMS=[],
|
||||
EXCLUDED_SINGLE_EXT=[],
|
||||
EXCLUDED_SINGLE_FILES=[],
|
||||
EXCLUDED_MULTI_FILES=[],
|
||||
EXCLUDED_MULTI_PARTS_EXT=[],
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
STRUCTURE_TEMPLATES={"default": "{platform}/roms/{game}"},
|
||||
)
|
||||
|
||||
def test_init_uses_library_base_path(self, handler: FSPlatformsHandler):
|
||||
@@ -100,115 +113,93 @@ class TestFSPlatformsHandler:
|
||||
result = handler._exclude_platforms(platforms)
|
||||
assert result == platforms
|
||||
|
||||
def test_get_platforms_directory_structure_a(
|
||||
def test_get_platforms_directory_from_default_template(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test get_platforms_directory with Structure A (roms/{platform})"""
|
||||
config.has_structure_path_b = False
|
||||
"""Platforms are enumerated in the folder above `{platform}`"""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.get_platforms_directory()
|
||||
assert result == config.ROMS_FOLDER_NAME
|
||||
assert handler.get_platforms_directory() == "roms"
|
||||
|
||||
def test_get_platforms_directory_structure_b(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
def test_get_platforms_directory_is_the_library_root_when_platform_leads(
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test get_platforms_directory with Structure B ({platform}/roms)"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = True
|
||||
"""A `{platform}/roms` template puts the platform folders at the root"""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
result = handler.get_platforms_directory()
|
||||
assert result == ""
|
||||
assert handler.get_platforms_directory() == ""
|
||||
|
||||
def test_get_platform_fs_structure_structure_a(
|
||||
def test_get_platform_fs_structure_from_default_template(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test get_platform_fs_structure with Structure A (roms/{platform})"""
|
||||
fs_slug = "n64"
|
||||
config.has_structure_path_b = False
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.get_platform_fs_structure(fs_slug)
|
||||
assert result == f"{config.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
assert handler.get_platform_fs_structure("n64") == "roms/n64"
|
||||
|
||||
def test_get_platform_fs_structure_structure_b(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
def test_get_platform_fs_structure_when_platform_leads(
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test get_platform_fs_structure with Structure B ({platform}/roms)"""
|
||||
fs_slug = "n64"
|
||||
config.has_structure_path_b = True
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
result = handler.get_platform_fs_structure(fs_slug)
|
||||
assert result == f"{fs_slug}/{config.ROMS_FOLDER_NAME}"
|
||||
assert handler.get_platform_fs_structure("n64") == "n64/roms"
|
||||
|
||||
def test_get_platform_fs_structure_custom_folder_name(
|
||||
self, handler: FSPlatformsHandler, config_custom_folder
|
||||
):
|
||||
"""Test get_platform_fs_structure with custom folder name (Structure B)"""
|
||||
fs_slug = "psx"
|
||||
config_custom_folder.has_structure_path_b = True
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_custom_folder,
|
||||
):
|
||||
result = handler.get_platform_fs_structure(fs_slug)
|
||||
assert result == f"{fs_slug}/{config_custom_folder.ROMS_FOLDER_NAME}"
|
||||
assert handler.get_platform_fs_structure("psx") == "ROMS/psx"
|
||||
|
||||
async def test_add_platform_creates_directory(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test that add_platform creates the correct directory (Structure A)"""
|
||||
fs_slug = "gba"
|
||||
expected_path = f"{config.ROMS_FOLDER_NAME}/{fs_slug}"
|
||||
config.has_structure_path_b = False
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
with patch.object(handler, "make_directory") as mock_make_directory:
|
||||
await handler.add_platform(fs_slug)
|
||||
mock_make_directory.assert_called_once_with(expected_path)
|
||||
await handler.add_platform("gba")
|
||||
mock_make_directory.assert_called_once_with("roms/gba")
|
||||
|
||||
async def test_add_platform_normal_structure(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
async def test_add_platform_follows_the_configured_template(
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test that add_platform creates directory with Structure B"""
|
||||
fs_slug = "gba"
|
||||
expected_path = f"{fs_slug}/{config.ROMS_FOLDER_NAME}"
|
||||
config.has_structure_path_b = True
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
with patch.object(handler, "make_directory") as mock_make_directory:
|
||||
await handler.add_platform(fs_slug)
|
||||
mock_make_directory.assert_called_once_with(expected_path)
|
||||
await handler.add_platform("gba")
|
||||
mock_make_directory.assert_called_once_with("gba/roms")
|
||||
|
||||
async def test_get_platforms_returns_existing_platforms(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test that get_platforms returns existing platforms"""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
result = await handler.get_platforms()
|
||||
assert "n64" in result
|
||||
assert "psx" in result
|
||||
|
||||
async def test_get_platforms_excludes_excluded_platforms(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test that get_platforms excludes excluded platforms"""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
config.EXCLUDED_PLATFORMS = ["psx"]
|
||||
config_platform_first.EXCLUDED_PLATFORMS = ["psx"]
|
||||
result = await handler.get_platforms()
|
||||
|
||||
assert "n64" in result
|
||||
@@ -217,8 +208,6 @@ class TestFSPlatformsHandler:
|
||||
async def test_get_platforms_calls_list_directories_with_correct_path(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test that get_platforms calls list_directories with correct path"""
|
||||
config.has_structure_path_a = True
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
@@ -226,16 +215,15 @@ class TestFSPlatformsHandler:
|
||||
handler, "list_directories", return_value=[]
|
||||
) as mock_list:
|
||||
await handler.get_platforms()
|
||||
mock_list.assert_called_once_with(path=config.ROMS_FOLDER_NAME)
|
||||
mock_list.assert_called_once_with(path="roms")
|
||||
|
||||
async def test_get_platforms_calls_list_directories_with_empty_path(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
self, handler: FSPlatformsHandler, config_platform_first
|
||||
):
|
||||
"""Test that get_platforms calls list_directories with empty path for normal structure"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = True
|
||||
"""A `{platform}/roms` template enumerates platforms at the library root"""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_platform_first,
|
||||
):
|
||||
with patch.object(
|
||||
handler, "list_directories", return_value=[]
|
||||
@@ -243,13 +231,11 @@ class TestFSPlatformsHandler:
|
||||
await handler.get_platforms()
|
||||
mock_list.assert_called_once_with(path="")
|
||||
|
||||
async def test_get_platforms_bootstraps_structure_a_when_none_detected(
|
||||
async def test_get_platforms_bootstraps_the_platforms_folder(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""When no structure exists, get_platforms creates Structure A (roms folder)
|
||||
and returns an empty list instead of raising."""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = False
|
||||
"""When the platforms folder is missing, get_platforms creates it and
|
||||
returns an empty list instead of raising."""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
@@ -268,8 +254,6 @@ class TestFSPlatformsHandler:
|
||||
"""If creating the default structure fails, get_platforms still returns an
|
||||
empty list rather than propagating the error (so the heartbeat stays healthy).
|
||||
"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = False
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
@@ -285,34 +269,6 @@ class TestFSPlatformsHandler:
|
||||
|
||||
assert result == []
|
||||
|
||||
async def test_get_platforms_skips_unreadable_directories(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Structure B: directories that raise PermissionError on stat are skipped
|
||||
instead of crashing platform discovery (and the heartbeat with it)."""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = True
|
||||
|
||||
class FakePath:
|
||||
def __init__(self, path: str):
|
||||
self._path = str(path)
|
||||
|
||||
async def exists(self) -> bool:
|
||||
if "locked" in self._path:
|
||||
raise PermissionError(13, "Permission denied", self._path)
|
||||
return True
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
with patch.object(
|
||||
handler, "list_directories", return_value=["n64", "locked", "psx"]
|
||||
):
|
||||
with patch("handler.filesystem.platforms_handler.AnyioPath", FakePath):
|
||||
result = await handler.get_platforms()
|
||||
|
||||
assert result == ["n64", "psx"]
|
||||
|
||||
def test_integration_with_base_handler_methods(self, handler: FSPlatformsHandler):
|
||||
"""Test that FSPlatformsHandler properly inherits from FSHandler"""
|
||||
# Test that handler has base methods
|
||||
@@ -327,13 +283,10 @@ class TestFSPlatformsHandler:
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test that platform slugs with special characters are handled correctly"""
|
||||
fs_slug = "n64"
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.get_platform_fs_structure(fs_slug)
|
||||
assert result == f"{fs_slug}/{config.ROMS_FOLDER_NAME}"
|
||||
assert handler.get_platform_fs_structure("n64") == "roms/n64"
|
||||
|
||||
async def test_path_construction_consistency(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
@@ -360,9 +313,8 @@ class TestFSPlatformsHandler:
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
for platform in existing_platforms:
|
||||
expected_path = f"{platform}/{config.ROMS_FOLDER_NAME}"
|
||||
result = handler.get_platform_fs_structure(platform)
|
||||
assert result == expected_path
|
||||
assert result == f"roms/{platform}"
|
||||
|
||||
async def test_edge_cases_and_error_handling(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
@@ -372,15 +324,12 @@ class TestFSPlatformsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.get_platform_fs_structure("")
|
||||
assert result == f"/{config.ROMS_FOLDER_NAME}"
|
||||
assert handler.get_platform_fs_structure("") == "roms/"
|
||||
|
||||
# Test adding empty platform
|
||||
with patch.object(handler, "make_directory") as mock_make_directory:
|
||||
await handler.add_platform("")
|
||||
mock_make_directory.assert_called_once_with(
|
||||
f"/{config.ROMS_FOLDER_NAME}"
|
||||
)
|
||||
mock_make_directory.assert_called_once_with("roms/")
|
||||
|
||||
def test_multiple_platforms_handling(self, handler: FSPlatformsHandler, config):
|
||||
"""Test handling multiple platforms simultaneously"""
|
||||
@@ -396,68 +345,39 @@ class TestFSPlatformsHandler:
|
||||
# Test that each platform gets correct structure
|
||||
for platform in expected_filtered:
|
||||
structure = handler.get_platform_fs_structure(platform)
|
||||
assert structure == f"{platform}/{config.ROMS_FOLDER_NAME}"
|
||||
assert structure == f"roms/{platform}"
|
||||
|
||||
def test_detect_library_structure_structure_a(
|
||||
def test_library_structure_exists_when_the_platforms_folder_is_present(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test detect_library_structure detects Structure A (roms/{platform})"""
|
||||
config.has_structure_path_a = True
|
||||
config.has_structure_path_b = False
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.detect_library_structure()
|
||||
assert result == LibraryStructure.A
|
||||
with patch("handler.filesystem.platforms_handler.os.path.isdir") as isdir:
|
||||
isdir.return_value = True
|
||||
assert handler.library_structure_exists() is True
|
||||
assert isdir.call_args[0][0].endswith("/roms")
|
||||
|
||||
def test_detect_library_structure_structure_b(
|
||||
def test_library_structure_exists_is_false_for_an_empty_library(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test detect_library_structure detects Structure B ({platform}/roms)"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = True
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.detect_library_structure()
|
||||
assert result == LibraryStructure.B
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.os.path.isdir",
|
||||
return_value=False,
|
||||
):
|
||||
assert handler.library_structure_exists() is False
|
||||
|
||||
def test_detect_library_structure_a_takes_priority_over_b(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
def test_library_structure_follows_the_configured_template(
|
||||
self, handler: FSPlatformsHandler, config_custom_folder
|
||||
):
|
||||
"""Structure A is reported when the top-level roms folder exists, even
|
||||
when Structure B directories are also present."""
|
||||
config.has_structure_path_a = True
|
||||
config.has_structure_path_b = True
|
||||
|
||||
"""The folder checked and created is the one the template names."""
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
"handler.filesystem.platforms_handler.cm.get_config",
|
||||
return_value=config_custom_folder,
|
||||
):
|
||||
result = handler.detect_library_structure()
|
||||
assert result == LibraryStructure.A
|
||||
|
||||
def test_detect_library_structure_none(self, handler: FSPlatformsHandler, config):
|
||||
"""Test detect_library_structure returns None when no structure detected"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = False
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.detect_library_structure()
|
||||
assert result is None
|
||||
|
||||
def test_detect_library_structure_empty_library(
|
||||
self, handler: FSPlatformsHandler, config
|
||||
):
|
||||
"""Test detect_library_structure with empty library directory"""
|
||||
config.has_structure_path_a = False
|
||||
config.has_structure_path_b = False
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
|
||||
):
|
||||
result = handler.detect_library_structure()
|
||||
assert result is None
|
||||
with patch("handler.filesystem.platforms_handler.os.makedirs") as makedirs:
|
||||
handler.create_library_structure()
|
||||
assert makedirs.call_args[0][0].endswith("/ROMS")
|
||||
|
||||
@@ -51,8 +51,10 @@ class TestFSRomsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=["excluded_part.bin"],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
@@ -119,51 +121,22 @@ class TestFSRomsHandler:
|
||||
"""Test that FSRomsHandler initializes with LIBRARY_BASE_PATH"""
|
||||
assert handler.base_path == Path(LIBRARY_BASE_PATH).resolve()
|
||||
|
||||
def test_get_roms_fs_structure_structure_b(self, handler: FSRomsHandler):
|
||||
"""Test get_roms_fs_structure with Structure B ({platform}/roms)"""
|
||||
fs_slug = "n64"
|
||||
cnfg = Config(
|
||||
EXCLUDED_PLATFORMS=[],
|
||||
EXCLUDED_SINGLE_EXT=[],
|
||||
EXCLUDED_SINGLE_FILES=[],
|
||||
EXCLUDED_MULTI_FILES=[],
|
||||
EXCLUDED_MULTI_PARTS_EXT=[],
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
)
|
||||
cnfg.has_structure_path_b = True
|
||||
@pytest.mark.parametrize(
|
||||
("template", "expected"),
|
||||
[
|
||||
("{platform}/roms/{game}", "n64/roms"),
|
||||
("roms/{platform}/{game}", "roms/n64"),
|
||||
("games/all/{platform}/{game}", "games/all/n64"),
|
||||
],
|
||||
)
|
||||
def test_get_roms_fs_structure(self, handler: FSRomsHandler, template, expected):
|
||||
"""The platform folder is whatever the template puts `{platform}` in."""
|
||||
cnfg = Config(STRUCTURE_TEMPLATES={"default": template})
|
||||
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: cnfg)
|
||||
|
||||
result = handler.get_roms_fs_structure(fs_slug)
|
||||
assert result == f"{fs_slug}/roms"
|
||||
|
||||
def test_get_roms_fs_structure_structure_a(self, handler: FSRomsHandler):
|
||||
"""Test get_roms_fs_structure with Structure A (roms/{platform})"""
|
||||
fs_slug = "n64"
|
||||
cnfg = Config(
|
||||
EXCLUDED_PLATFORMS=[],
|
||||
EXCLUDED_SINGLE_EXT=[],
|
||||
EXCLUDED_SINGLE_FILES=[],
|
||||
EXCLUDED_MULTI_FILES=[],
|
||||
EXCLUDED_MULTI_PARTS_EXT=[],
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
)
|
||||
cnfg.has_structure_path_b = False
|
||||
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: cnfg)
|
||||
|
||||
result = handler.get_roms_fs_structure(fs_slug)
|
||||
assert result == f"roms/{fs_slug}"
|
||||
assert handler.get_roms_fs_structure("n64") == expected
|
||||
|
||||
def test_parse_tags_regions_and_languages(self, handler: FSRomsHandler):
|
||||
"""Test parse_tags method with regions and languages"""
|
||||
@@ -377,8 +350,10 @@ class TestFSRomsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
@@ -504,7 +479,7 @@ class TestFSRomsHandler:
|
||||
|
||||
# Check that we have both single and multi ROMs
|
||||
single_roms = [r for r in result if not r["flat"]]
|
||||
multi_roms = [r for r in result if r["nested"]]
|
||||
multi_roms = [r for r in result if not r["flat"]]
|
||||
|
||||
assert len(single_roms) > 0
|
||||
assert len(multi_roms) > 0
|
||||
@@ -528,9 +503,7 @@ class TestFSRomsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES=templates,
|
||||
STRUCTURE_TEMPLATES={"default": "{platform}/roms/{game}", **templates},
|
||||
)
|
||||
|
||||
def _build_structure_library(self, tmp_path: Path, base: str) -> None:
|
||||
@@ -588,18 +561,18 @@ class TestFSRomsHandler:
|
||||
assert count == len(roms)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_roms_structure_wildcard_file_terminal(
|
||||
async def test_get_roms_structure_wildcard_level(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
):
|
||||
"""`{category}/{gameFile}` descends one wildcard level and treats each
|
||||
file as a rom; hidden folders are skipped and identically-named files in
|
||||
different folders stay distinct via their full path."""
|
||||
"""A wildcard level descends one folder and the `{game}` terminal takes
|
||||
both the files and the folders it finds there; hidden folders are skipped
|
||||
and identically-named games in different folders stay distinct."""
|
||||
handler = FSRomsHandler()
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{category}/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/{category}/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -607,14 +580,17 @@ class TestFSRomsHandler:
|
||||
roms = await handler.get_roms(platform)
|
||||
count = await handler.count_roms(platform)
|
||||
|
||||
keys = {(r["fs_path"], r["fs_name"]) for r in roms}
|
||||
assert (f"{base}/Hacks", "Shared.zip") in keys
|
||||
by_key = {(r["fs_path"], r["fs_name"]): r for r in roms}
|
||||
keys = set(by_key)
|
||||
# A file at the terminal level is a game of its own...
|
||||
assert by_key[(f"{base}/Hacks", "Shared.zip")]["flat"] is True
|
||||
assert (f"{base}/Hacks", "HackOnly.zip") in keys
|
||||
assert (f"{base}/Translations", "Shared.zip") in keys # collision kept
|
||||
# ...and a folder there is one multi-file game, kept whole.
|
||||
assert by_key[(f"{base}/Hacks", "Inner")]["flat"] is False
|
||||
assert (f"{base}/Hacks/Inner", "x.bin") not in keys
|
||||
# Top-level file isn't surfaced (template requires one level down).
|
||||
assert (base, "Top.zip") not in keys
|
||||
# A folder at the terminal level isn't a {gameFile} rom.
|
||||
assert (f"{base}/Hacks", "Inner") not in keys
|
||||
# Hidden folder is never descended into.
|
||||
assert not any(r["fs_path"].endswith("/.hidden") for r in roms)
|
||||
full_paths = [f"{r['fs_path']}/{r['fs_name']}" for r in roms]
|
||||
@@ -622,36 +598,6 @@ class TestFSRomsHandler:
|
||||
assert sum(1 for r in roms if r["fs_name"] == "Shared.zip") == 2
|
||||
assert count == len(roms)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_roms_structure_wildcard_dir_terminal(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
):
|
||||
"""`{category}/{gameDir}` treats each folder at the terminal level as a
|
||||
single multi-file rom (kept whole, no disc-splitting guesswork)."""
|
||||
handler = FSRomsHandler()
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{category}/{gameDir}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
self._build_structure_library(tmp_path, base)
|
||||
roms = await handler.get_roms(platform)
|
||||
count = await handler.count_roms(platform)
|
||||
|
||||
keys = {(r["fs_path"], r["fs_name"]) for r in roms}
|
||||
# Folders at the terminal level become whole multi-file roms...
|
||||
assert (f"{base}/Hacks", "Inner") in keys
|
||||
assert (f"{base}/Region", "USA") in keys
|
||||
# ...and are not split into their contents.
|
||||
assert (f"{base}/Hacks/Inner", "x.bin") not in keys
|
||||
# Files at the terminal level are not {gameDir} roms.
|
||||
assert (f"{base}/Hacks", "Shared.zip") not in keys
|
||||
assert all(r["nested"] for r in roms)
|
||||
assert count == len(roms)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_roms_structure_two_wildcard_levels(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
@@ -662,7 +608,7 @@ class TestFSRomsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{region}/{system}/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/{region}/{system}/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -687,7 +633,9 @@ class TestFSRomsHandler:
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config({platform.fs_slug: "Hacks/{gameFile}"}),
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{platform}/roms/Hacks/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
self._build_structure_library(tmp_path, base)
|
||||
@@ -706,16 +654,20 @@ class TestFSRomsHandler:
|
||||
async def test_get_roms_structure_list_unions_loose_and_grouped(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
):
|
||||
"""A list of templates unions their discovery: loose top-level games
|
||||
(`{gameFile}`) plus games inside grouping subfolders
|
||||
(`{category}/{gameFile}`), the common mixed layout, without dropping
|
||||
either, deduplicated by full path."""
|
||||
"""A list of templates unions their discovery: games in the platform
|
||||
folder plus games inside grouping subfolders, the common mixed layout,
|
||||
without dropping either, deduplicated by full path."""
|
||||
handler = FSRomsHandler()
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: ["{gameFile}", "{category}/{gameFile}"]}
|
||||
{
|
||||
platform.fs_slug: [
|
||||
"{platform}/roms/{game}",
|
||||
"{platform}/roms/{category}/{game}",
|
||||
]
|
||||
}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -724,9 +676,9 @@ class TestFSRomsHandler:
|
||||
count = await handler.count_roms(platform)
|
||||
|
||||
keys = {(r["fs_path"], r["fs_name"]) for r in roms}
|
||||
# Loose top-level game ({gameFile}).
|
||||
# Loose game in the platform folder.
|
||||
assert (base, "Top.zip") in keys
|
||||
# Grouped games one level down ({category}/{gameFile}).
|
||||
# Grouped games one level down.
|
||||
assert (f"{base}/Hacks", "Shared.zip") in keys
|
||||
assert (f"{base}/Hacks", "HackOnly.zip") in keys
|
||||
assert (f"{base}/Translations", "Shared.zip") in keys
|
||||
@@ -740,14 +692,19 @@ class TestFSRomsHandler:
|
||||
async def test_get_roms_grouping_folder_is_not_also_a_game(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
):
|
||||
"""`{gameDir}` at the root must not claim a folder another template
|
||||
"""A `{game}` at the root must not claim a folder another template
|
||||
descends into: `Hacks` is a category here, not a multi-file game."""
|
||||
handler = FSRomsHandler()
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: ["{gameDir}", "{category}/{gameFile}"]}
|
||||
{
|
||||
platform.fs_slug: [
|
||||
"{platform}/roms/{game}",
|
||||
"{platform}/roms/{category}/{game}",
|
||||
]
|
||||
}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -756,27 +713,30 @@ class TestFSRomsHandler:
|
||||
count = await handler.count_roms(platform)
|
||||
|
||||
keys = {(r["fs_path"], r["fs_name"]) for r in roms}
|
||||
# Descended into, so a category rather than a game.
|
||||
# Descended into, so categories rather than games.
|
||||
assert (base, "Hacks") not in keys
|
||||
assert (base, "Translations") not in keys
|
||||
# Its contents are the games.
|
||||
assert (base, "Region") not in keys
|
||||
# Their contents are the games, files and folders alike.
|
||||
assert (f"{base}/Hacks", "HackOnly.zip") in keys
|
||||
# A folder no template descends into is still a multi-file game.
|
||||
assert (base, "Region") in keys
|
||||
assert (f"{base}/Hacks", "Inner") in keys
|
||||
assert (f"{base}/Region", "USA") in keys
|
||||
# A loose file in the platform folder is still a game of its own.
|
||||
assert (base, "Top.zip") in keys
|
||||
assert count == len(roms)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_roms_default_layout_nested_under_a_category(
|
||||
self, platform: Platform, tmp_path: Path
|
||||
):
|
||||
"""`{category}/{gameFile}` + `{category}/{gameDir}` reproduces the
|
||||
default scan one level down: each file a game, each folder a game."""
|
||||
"""One `{category}/{game}` template reproduces the default scan a level
|
||||
down: each file a game, each folder a game."""
|
||||
handler = FSRomsHandler()
|
||||
handler.base_path = tmp_path
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: ["{category}/{gameFile}", "{category}/{gameDir}"]}
|
||||
{platform.fs_slug: "{platform}/roms/{category}/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -786,8 +746,8 @@ class TestFSRomsHandler:
|
||||
|
||||
by_key = {(r["fs_path"], r["fs_name"]): r for r in roms}
|
||||
assert by_key[(f"{base}/Hacks", "HackOnly.zip")]["flat"] is True
|
||||
assert by_key[(f"{base}/Hacks", "Inner")]["nested"] is True
|
||||
assert by_key[(f"{base}/Region", "USA")]["nested"] is True
|
||||
assert by_key[(f"{base}/Hacks", "Inner")]["flat"] is False
|
||||
assert by_key[(f"{base}/Region", "USA")]["flat"] is False
|
||||
# The top level holds no games under this template.
|
||||
assert not any(r["fs_path"] == base for r in roms)
|
||||
assert count == len(roms)
|
||||
@@ -803,7 +763,7 @@ class TestFSRomsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{category}/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/{category}/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -828,7 +788,7 @@ class TestFSRomsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "@eaDir/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/@eaDir/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -862,7 +822,7 @@ class TestFSRomsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "Games/Loose/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/Games/Loose/{game}"}
|
||||
),
|
||||
):
|
||||
base = handler.get_roms_fs_structure(platform.fs_slug)
|
||||
@@ -873,17 +833,16 @@ class TestFSRomsHandler:
|
||||
def test_upload_path_prefers_a_template_an_upload_can_satisfy(
|
||||
self, platform: Platform
|
||||
):
|
||||
"""Only a `{gameFile}` terminal makes a loose file a rom of its own, and
|
||||
only literal levels name the folder it has to go in."""
|
||||
"""Only literal levels name the folder an upload has to go in, so a
|
||||
template with a wildcard is skipped for the next one that pins it down."""
|
||||
handler = FSRomsHandler()
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{
|
||||
platform.fs_slug: [
|
||||
"{category}/{gameFile}",
|
||||
"{gameDir}",
|
||||
"Loose/{gameFile}",
|
||||
"{platform}/roms/{category}/{game}",
|
||||
"{platform}/roms/Loose/{game}",
|
||||
]
|
||||
}
|
||||
),
|
||||
@@ -898,7 +857,7 @@ class TestFSRomsHandler:
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config",
|
||||
lambda: self._make_structure_config(
|
||||
{platform.fs_slug: "{category}/{gameFile}"}
|
||||
{platform.fs_slug: "{platform}/roms/{category}/{game}"}
|
||||
),
|
||||
):
|
||||
with pytest.raises(ValueError, match="custom library structure"):
|
||||
@@ -1018,8 +977,10 @@ class TestFSRomsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr(
|
||||
@@ -1040,8 +1001,10 @@ class TestFSRomsHandler:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr(
|
||||
@@ -1222,20 +1185,11 @@ class TestFSRomsHandler:
|
||||
|
||||
def test_rom_fs_structure_consistency(self, handler: FSRomsHandler, config):
|
||||
"""Test that ROM filesystem structure is consistent across methods"""
|
||||
fs_slug = "gba"
|
||||
|
||||
with pytest.MonkeyPatch.context() as m:
|
||||
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: config)
|
||||
|
||||
# Test with Structure B
|
||||
config.has_structure_path_b = True
|
||||
structure = handler.get_roms_fs_structure(fs_slug)
|
||||
assert structure == f"{fs_slug}/roms"
|
||||
|
||||
# Test with Structure A
|
||||
config.has_structure_path_b = False
|
||||
structure = handler.get_roms_fs_structure(fs_slug)
|
||||
assert structure == f"roms/{fs_slug}"
|
||||
assert handler.get_roms_fs_structure("gba") == "gba/roms"
|
||||
assert handler.get_roms_upload_path("gba") == "gba/roms"
|
||||
|
||||
def test_actual_file_hash_calculation(self, handler: FSRomsHandler):
|
||||
"""Test hash calculation with actual files"""
|
||||
@@ -1793,10 +1747,11 @@ def sigil_config(monkeypatch):
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
cnfg.has_structure_path_b = True
|
||||
monkeypatch.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: cnfg)
|
||||
return cnfg
|
||||
|
||||
@@ -2919,8 +2874,10 @@ class TestIncrementalRomFiles:
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
)
|
||||
mocker.patch(
|
||||
"handler.filesystem.roms_handler.cm.get_config", return_value=config
|
||||
|
||||
@@ -58,8 +58,10 @@ def _make_config(
|
||||
EXCLUDED_MULTI_PARTS_FILES=[],
|
||||
PLATFORMS_BINDING={},
|
||||
PLATFORMS_VERSIONS={},
|
||||
ROMS_FOLDER_NAME="roms",
|
||||
FIRMWARE_FOLDER_NAME="bios",
|
||||
STRUCTURE_TEMPLATES={
|
||||
"default": "{platform}/roms/{game}",
|
||||
"firmware": "{platform}/bios",
|
||||
},
|
||||
SCAN_REGION_PRIORITY=region_priority or [],
|
||||
SCAN_LANGUAGE_PRIORITY=(
|
||||
language_priority if language_priority is not None else ["en"]
|
||||
|
||||
@@ -50,7 +50,6 @@ async def run_scan(
|
||||
"fs_name": rom.fs_name,
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
|
||||
@@ -92,7 +92,6 @@ async def test_scan_rom():
|
||||
"fs_name": "Paper Mario (USA).z64",
|
||||
"fs_path": "n64/Paper Mario (USA)",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [
|
||||
RomFile(
|
||||
rom=rom,
|
||||
@@ -183,7 +182,6 @@ async def test_scan_rom_complete_clears_unselected_metadata(
|
||||
"fs_name": "Paper Mario (USA).z64",
|
||||
"fs_path": "n64/Paper Mario (USA)",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -243,7 +241,6 @@ async def test_scan_rom_folds_extracted_title_id_values(
|
||||
"fs_name": "Game.nsp",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [
|
||||
RomFile(
|
||||
rom=rom,
|
||||
@@ -325,7 +322,6 @@ async def test_scan_rom_unmatched_fetches_ra_when_id_set_but_no_metadata(
|
||||
"fs_name": "Jak and Daxter.chd",
|
||||
"fs_path": "ps2",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -388,7 +384,6 @@ async def test_scan_rom_unmatched_skips_ra_when_id_and_metadata_exist(
|
||||
"fs_name": "Jak and Daxter.chd",
|
||||
"fs_path": "ps2",
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -455,7 +450,6 @@ async def test_scan_rom_unmatched_replaces_placeholder_name(
|
||||
"fs_name": "Snow Brothers (USA).zip",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -519,7 +513,6 @@ async def test_scan_rom_unmatched_preserves_custom_name(
|
||||
"fs_name": "Snow Brothers (USA).zip",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -578,7 +571,6 @@ async def test_scan_rom_unmatched_no_match_uses_parsed_name(
|
||||
"fs_name": "Snow Brothers (USA).zip",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
@@ -810,7 +802,6 @@ async def test_scan_rom_hashes_rematches_hasheous(
|
||||
"fs_name": "Snow Brothers (USA).7z",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "newcrc",
|
||||
"md5_hash": "newmd5",
|
||||
@@ -886,7 +877,6 @@ async def test_scan_rom_hashes_clears_stale_hasheous_match(
|
||||
"fs_name": "Snow Brothers (USA).7z",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "changedcrc",
|
||||
"md5_hash": "changedmd5",
|
||||
@@ -937,7 +927,6 @@ async def test_scan_rom_hashes_keeps_match_when_hasheous_unreachable(
|
||||
"fs_name": "Snow Brothers (USA).7z",
|
||||
"fs_path": rom.fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "changedcrc",
|
||||
"md5_hash": "changedmd5",
|
||||
@@ -1134,7 +1123,6 @@ def _ss_quota_fs_rom(fs_name: str, fs_path: str = "n64/roms") -> FSRom:
|
||||
"fs_name": fs_name,
|
||||
"fs_path": fs_path,
|
||||
"flat": True,
|
||||
"nested": False,
|
||||
"files": [],
|
||||
"crc_hash": "",
|
||||
"md5_hash": "",
|
||||
|
||||
@@ -8,6 +8,7 @@ from rq.job import Job
|
||||
from watcher import EventType, get_pending_scan_coverage, process_changes
|
||||
|
||||
from config import LIBRARY_BASE_PATH
|
||||
from config.config_manager import parse_structure_template
|
||||
from handler.scan_handler import ScanType
|
||||
|
||||
_job_ids = count()
|
||||
@@ -131,7 +132,7 @@ class TestProcessChanges:
|
||||
@pytest.fixture(autouse=True)
|
||||
def library_layout(self, mocker):
|
||||
config = MagicMock()
|
||||
config.has_structure_path_b = False
|
||||
config.default_structure = parse_structure_template("roms/{platform}/{game}")
|
||||
config.EXCLUDED_SINGLE_FILES = []
|
||||
config.EXCLUDED_MULTI_FILES = []
|
||||
config.EXCLUDED_MULTI_PARTS_FILES = []
|
||||
|
||||
@@ -132,7 +132,9 @@ def process_changes(changes: Sequence[Change]) -> None:
|
||||
# exact-match and fnmatch patterns for files, plus excluded directory names
|
||||
# checked against every path component so events inside excluded dirs are ignored.
|
||||
cnfg = cm.get_config()
|
||||
structure_level = 1 if cnfg.has_structure_path_b else 2
|
||||
# Index of the platform segment in a library-relative event path, which
|
||||
# leads with an empty segment for the separator.
|
||||
structure_level = len(cnfg.default_structure.platform_dir) + 1
|
||||
excluded_patterns = (
|
||||
cnfg.EXCLUDED_SINGLE_FILES
|
||||
+ cnfg.EXCLUDED_MULTI_FILES
|
||||
|
||||
@@ -1661,8 +1661,10 @@ exclude:
|
||||
names: ["__MACOSX"]
|
||||
|
||||
filesystem:
|
||||
roms_folder: "roms" # Subfolder name for ROMs
|
||||
firmware_folder: "bios" # Subfolder name for BIOS
|
||||
structure: # Library layout; `{platform}` is the platform folder, `{game}` where a game begins
|
||||
default: "roms/{platform}/{game}"
|
||||
firmware: "bios/{platform}"
|
||||
ps3: "roms/{platform}/{category}/{game}" # Per-platform override, by fs_slug
|
||||
skip_hash_calculation: false
|
||||
skip_title_id_extraction: false # Skip sigil title ID extraction
|
||||
embed_switch_title_ids: false # Rename Switch ROMs to embed their title ID
|
||||
|
||||
@@ -72,33 +72,36 @@
|
||||
# naomi: arcade
|
||||
|
||||
# filesystem:
|
||||
# # Custom games folder name only (eg. `retro_games/`)
|
||||
# roms_folder: 'roms'
|
||||
# # Skip file hash calculations on low power devices (eg. Raspberry PI)
|
||||
# skip_hash_calculation: false
|
||||
# # Skip reading platform-native title IDs out of ROM binaries during scans
|
||||
# skip_title_id_extraction: false
|
||||
# # Rename Switch ROMs to embed ` [TITLEID][vVERSION]` in their filename
|
||||
# embed_switch_title_ids: false
|
||||
# # Custom library structure, per platform (by fs_slug). Opt-in: platforms left
|
||||
# # out keep the default one-level-deep scan, where each top-level file is a
|
||||
# # game and each top-level folder is a single multi-file game. A template is a
|
||||
# # `/`-separated path relative to the platform's ROM folder, ending in a
|
||||
# # terminal macro: {gameFile} (each file at that level is a game) or {gameDir}
|
||||
# # (each folder at that level is one multi-file game). Any other braced
|
||||
# # section is a wildcard folder level, purely organizational. A platform can
|
||||
# # declare a list of templates, and discovery is their union.
|
||||
# # Library structure. A template is a `/`-separated path relative to the
|
||||
# # library root, where `{platform}` marks the platform folder and the final
|
||||
# # `{game}` marks where a game begins (a file there is a game of its own, a
|
||||
# # folder there is one multi-file game). Any other braced section is a
|
||||
# # wildcard folder level, purely organizational. Sections before `{platform}`
|
||||
# # must be literal folder names.
|
||||
# # https://docs.romm.app/latest/getting-started/folder-structure/#custom-library-structure
|
||||
# structure:
|
||||
# # Loose top-level games AND games inside grouping subfolders, e.g.
|
||||
# # The library-wide layout. This is the default; set it to rename the games
|
||||
# # folder (eg. `retro_games/{platform}/{game}`) or to put the platform
|
||||
# # folder first (`{platform}/roms/{game}`).
|
||||
# default: 'roms/{platform}/{game}'
|
||||
# # Where each platform's firmware lives. A folder, so no `{game}`.
|
||||
# firmware: 'bios/{platform}'
|
||||
# # Per-platform overrides, by fs_slug. Discovery is the union of the
|
||||
# # templates listed, so one platform can mix layouts:
|
||||
# # roms/nes/game01.nes and roms/nes/Hacks/game03.nes
|
||||
# nes:
|
||||
# - '{gameFile}'
|
||||
# - '{category}/{gameFile}'
|
||||
# - 'roms/{platform}/{game}'
|
||||
# - 'roms/{platform}/{category}/{game}'
|
||||
# # roms/ps3/Disc/Game/, roms/ps3/PSN/Game/ -> each folder a multi-file game
|
||||
# ps3: '{category}/{gameDir}'
|
||||
# ps3: 'roms/{platform}/{category}/{game}'
|
||||
# # roms/snes/USA/foo.sfc, roms/snes/Japan/bar.sfc
|
||||
# snes: '{region}/{gameFile}'
|
||||
# snes: 'roms/{platform}/{region}/{game}'
|
||||
|
||||
# scan:
|
||||
# # Metadata priority during scans
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Създай администраторски потребител",
|
||||
"cancel": "Откажи",
|
||||
"check-metadata-step": "Провери източници на метаданни",
|
||||
"confirm-create-platforms": "RomM ще създаде Структура {structure} ({pattern}) с {count} платформ{plural}. Продължи?",
|
||||
"confirm-create-platforms": "RomM ще създаде {pattern} с {count} платформ{plural}. Продължи?",
|
||||
"confirm-no-platforms": "Не е открита структура на папки и не са избрани платформи. Ще трябва да създадеш структурата на папките ръчно. Продължи?",
|
||||
"confirm-no-structure": "Не е открита структура на папки. RomM ще създаде Структура A (roms/{platform}) с {count} платформ{plural}. Продължи?",
|
||||
"confirm-no-structure": "Не е открита структура на папки. RomM ще създаде {pattern} с {count} платформ{plural}. Продължи?",
|
||||
"continue": "Продължи",
|
||||
"creating-platforms": "Създаване на папки…",
|
||||
"creating-platforms-failed": "Неуспешно създаване на папки за платформи",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "игра",
|
||||
"games": "игри",
|
||||
"identified": "Идентифицирани",
|
||||
"library-structure-detected": "Открита е структура на библиотеката",
|
||||
"library-structure-step": "Настрой структурата на библиотеката",
|
||||
"loading-library": "Преглед на библиотеката ти…",
|
||||
"loading-library-failed": "Неуспешно зареждане на информация за библиотеката",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Липсва API ключ",
|
||||
"metadata-status-unreachable": "Недостъпно",
|
||||
"next": "Напред",
|
||||
"no-structure-banner-body": "RomM ще създаде Структура A и ще добави избраните платформи в нея.",
|
||||
"no-structure-banner-body": "RomM ще създаде структурата на библиотеката и ще добави избраните платформи в нея.",
|
||||
"no-structure-banner-title": "Не е открита структура на библиотеката",
|
||||
"no-structure-detected": "Не е открита структура - ще бъде създадена Структура A",
|
||||
"no-structure-detected": "Не е открита структура - ще бъде създадена",
|
||||
"platform": "платформа",
|
||||
"platform-detected-with-games": "Открита · {count} игра | Открита · {count} игри",
|
||||
"platform-will-create": "Ще бъде създадена",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "избрани",
|
||||
"step-coming-soon": "Тази стъпка скоро ще бъде мигрирана.",
|
||||
"step-of": "Стъпка {current} от {total}",
|
||||
"structure-a-detected": "Открита е Структура A",
|
||||
"structure-b-detected": "Открита е Структура B",
|
||||
"structure-banner-games": "{count} игра | {count} игри",
|
||||
"structure-banner-platforms": "{count} платформа | {count} платформи",
|
||||
"supported-platforms": "Поддържани платформи",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Vytvořit administrátorského uživatele",
|
||||
"cancel": "Zrušit",
|
||||
"check-metadata-step": "Zkontrolovat zdroje metadat",
|
||||
"confirm-create-platforms": "RomM vytvoří strukturu {structure} ({pattern}) s {count} platforma{plural}. Pokračovat?",
|
||||
"confirm-create-platforms": "RomM vytvoří {pattern} s {count} platforma{plural}. Pokračovat?",
|
||||
"confirm-no-platforms": "Nebyla detekována žádná struktura složek a nebyly vybrány žádné platformy. Budete muset vytvořit strukturu složek ručně. Pokračovat?",
|
||||
"confirm-no-structure": "Nebyla detekována žádná struktura složek. RomM vytvoří strukturu A (roms/{platform}) s {count} platforma{plural}. Pokračovat?",
|
||||
"confirm-no-structure": "Nebyla detekována žádná struktura složek. RomM vytvoří {pattern} s {count} platforma{plural}. Pokračovat?",
|
||||
"continue": "Pokračovat",
|
||||
"creating-platforms": "Vytváření složek…",
|
||||
"creating-platforms-failed": "Nepodařilo se vytvořit složky platforem",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "hra",
|
||||
"games": "hry",
|
||||
"identified": "Identifikováno",
|
||||
"library-structure-detected": "Detekována struktura knihovny",
|
||||
"library-structure-step": "Nastavit strukturu knihovny",
|
||||
"loading-library": "Kontrola vaší knihovny…",
|
||||
"loading-library-failed": "Nepodařilo se načíst informace o knihovně",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Chybí API klíč",
|
||||
"metadata-status-unreachable": "Nedostupné",
|
||||
"next": "Další",
|
||||
"no-structure-banner-body": "RomM vytvoří strukturu A a vloží do ní vybrané platformy.",
|
||||
"no-structure-banner-body": "RomM vytvoří strukturu knihovny a vloží do ní vybrané platformy.",
|
||||
"no-structure-banner-title": "Nebyla detekována žádná struktura knihovny",
|
||||
"no-structure-detected": "Nebyla detekována žádná struktura - bude vytvořena struktura A",
|
||||
"no-structure-detected": "Nebyla detekována žádná struktura - bude vytvořena",
|
||||
"platform": "platforma",
|
||||
"platform-detected-with-games": "Detekováno · {count} her | Detekováno · {count} hra | Detekováno · {count} hry | Detekováno · {count} her",
|
||||
"platform-will-create": "Bude vytvořeno",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "vybráno",
|
||||
"step-coming-soon": "Tento krok bude brzy přenesen.",
|
||||
"step-of": "Krok {current} z {total}",
|
||||
"structure-a-detected": "Detekována struktura A",
|
||||
"structure-b-detected": "Detekována struktura B",
|
||||
"structure-banner-games": "{count} her | {count} hra | {count} hry | {count} her",
|
||||
"structure-banner-platforms": "{count} platforem | {count} platforma | {count} platformy | {count} platforem",
|
||||
"supported-platforms": "Dostupné platformy",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Administrator-Benutzer erstellen",
|
||||
"cancel": "Abbrechen",
|
||||
"check-metadata-step": "Metadatenquellen überprüfen",
|
||||
"confirm-create-platforms": "RomM erstellt Struktur {structure} ({pattern}) mit {count} Plattform{plural}. Fortfahren?",
|
||||
"confirm-create-platforms": "RomM erstellt {pattern} mit {count} Plattform{plural}. Fortfahren?",
|
||||
"confirm-no-platforms": "Keine Ordnerstruktur erkannt und keine Plattformen ausgewählt. Sie müssen die Ordnerstruktur manuell erstellen. Fortfahren?",
|
||||
"confirm-no-structure": "Keine Ordnerstruktur erkannt. RomM erstellt Struktur A (roms/{platform}) mit {count} Plattform{plural}. Fortfahren?",
|
||||
"confirm-no-structure": "Keine Ordnerstruktur erkannt. RomM erstellt {pattern} mit {count} Plattform{plural}. Fortfahren?",
|
||||
"continue": "Fortfahren",
|
||||
"creating-platforms": "Ordner werden erstellt…",
|
||||
"creating-platforms-failed": "Plattform-Ordner konnten nicht erstellt werden",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "Spiel",
|
||||
"games": "Spiele",
|
||||
"identified": "Identifiziert",
|
||||
"library-structure-detected": "Bibliotheksstruktur erkannt",
|
||||
"library-structure-step": "Bibliotheksstruktur einrichten",
|
||||
"loading-library": "Bibliothek wird geprüft…",
|
||||
"loading-library-failed": "Bibliotheksinformationen konnten nicht geladen werden",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API-Schlüssel fehlt",
|
||||
"metadata-status-unreachable": "Nicht erreichbar",
|
||||
"next": "Weiter",
|
||||
"no-structure-banner-body": "RomM wird Struktur A erstellen und die ausgewählten Plattformen darin ablegen.",
|
||||
"no-structure-banner-body": "RomM wird die Bibliotheksstruktur erstellen und die ausgewählten Plattformen darin ablegen.",
|
||||
"no-structure-banner-title": "Keine Bibliotheksstruktur erkannt",
|
||||
"no-structure-detected": "Keine Struktur erkannt - Struktur A wird erstellt",
|
||||
"no-structure-detected": "Keine Struktur erkannt - sie wird erstellt",
|
||||
"platform": "Plattform",
|
||||
"platform-detected-with-games": "Erkannt · {count} Spiel | Erkannt · {count} Spiele",
|
||||
"platform-will-create": "Wird erstellt",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "ausgewählt",
|
||||
"step-coming-soon": "Dieser Schritt wird bald migriert.",
|
||||
"step-of": "Schritt {current} von {total}",
|
||||
"structure-a-detected": "Struktur A erkannt",
|
||||
"structure-b-detected": "Struktur B erkannt",
|
||||
"structure-banner-games": "{count} Spiel | {count} Spiele",
|
||||
"structure-banner-platforms": "{count} Plattform | {count} Plattformen",
|
||||
"supported-platforms": "Verfügbare Plattformen",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Create an admin user",
|
||||
"cancel": "Cancel",
|
||||
"check-metadata-step": "Check metadata sources",
|
||||
"confirm-create-platforms": "RomM will create Structure {structure} ({pattern}) with {count} platform{plural}. Continue?",
|
||||
"confirm-create-platforms": "RomM will create {pattern} with {count} platform{plural}. Continue?",
|
||||
"confirm-no-platforms": "No folder structure detected and no platforms selected. You will need to create the folder structure manually. Continue?",
|
||||
"confirm-no-structure": "No folder structure detected. RomM will create Structure A (roms/{platform}) with {count} platform{plural}. Continue?",
|
||||
"confirm-no-structure": "No folder structure detected. RomM will create {pattern} with {count} platform{plural}. Continue?",
|
||||
"continue": "Continue",
|
||||
"creating-platforms": "Creating folders…",
|
||||
"creating-platforms-failed": "Failed to create platform folders",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "game",
|
||||
"games": "games",
|
||||
"identified": "Identified",
|
||||
"library-structure-detected": "Library structure detected",
|
||||
"library-structure-step": "Setup library structure",
|
||||
"loading-library": "Inspecting your library…",
|
||||
"loading-library-failed": "Failed to load library info",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API key missing",
|
||||
"metadata-status-unreachable": "Unreachable",
|
||||
"next": "Next",
|
||||
"no-structure-banner-body": "RomM will create Structure A and add the selected platforms inside.",
|
||||
"no-structure-banner-body": "RomM will create the library structure and add the selected platforms inside.",
|
||||
"no-structure-banner-title": "No library structure detected",
|
||||
"no-structure-detected": "No structure detected - Structure A will be created",
|
||||
"no-structure-detected": "No structure detected - it will be created",
|
||||
"platform": "platform",
|
||||
"platform-detected-with-games": "Detected · {count} game | Detected · {count} games",
|
||||
"platform-will-create": "Will create",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "selected",
|
||||
"step-coming-soon": "This step will be migrated soon.",
|
||||
"step-of": "Step {current} of {total}",
|
||||
"structure-a-detected": "Structure A detected",
|
||||
"structure-b-detected": "Structure B detected",
|
||||
"structure-banner-games": "{count} game | {count} games",
|
||||
"structure-banner-platforms": "{count} platform | {count} platforms",
|
||||
"supported-platforms": "Supported Platforms",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Create an admin user",
|
||||
"cancel": "Cancel",
|
||||
"check-metadata-step": "Check metadata sources",
|
||||
"confirm-create-platforms": "RomM will create Structure {structure} ({pattern}) with {count} platform{plural}. Continue?",
|
||||
"confirm-create-platforms": "RomM will create {pattern} with {count} platform{plural}. Continue?",
|
||||
"confirm-no-platforms": "No folder structure detected and no platforms selected. You will need to create the folder structure manually. Continue?",
|
||||
"confirm-no-structure": "No folder structure detected. RomM will create Structure A (roms/{platform}) with {count} platform{plural}. Continue?",
|
||||
"confirm-no-structure": "No folder structure detected. RomM will create {pattern} with {count} platform{plural}. Continue?",
|
||||
"continue": "Continue",
|
||||
"creating-platforms": "Creating folders…",
|
||||
"creating-platforms-failed": "Failed to create platform folders",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "game",
|
||||
"games": "games",
|
||||
"identified": "Identified",
|
||||
"library-structure-detected": "Library structure detected",
|
||||
"library-structure-step": "Setup library structure",
|
||||
"loading-library": "Inspecting your library…",
|
||||
"loading-library-failed": "Failed to load library info",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API key missing",
|
||||
"metadata-status-unreachable": "Unreachable",
|
||||
"next": "Next",
|
||||
"no-structure-banner-body": "RomM will create Structure A and add the selected platforms inside.",
|
||||
"no-structure-banner-body": "RomM will create the library structure and add the selected platforms inside.",
|
||||
"no-structure-banner-title": "No library structure detected",
|
||||
"no-structure-detected": "No structure detected - Structure A will be created",
|
||||
"no-structure-detected": "No structure detected - it will be created",
|
||||
"platform": "platform",
|
||||
"platform-detected-with-games": "Detected · {count} game | Detected · {count} games",
|
||||
"platform-will-create": "Will create",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "selected",
|
||||
"step-coming-soon": "This step will be migrated soon.",
|
||||
"step-of": "Step {current} of {total}",
|
||||
"structure-a-detected": "Structure A detected",
|
||||
"structure-b-detected": "Structure B detected",
|
||||
"structure-banner-games": "{count} game | {count} games",
|
||||
"structure-banner-platforms": "{count} platform | {count} platforms",
|
||||
"supported-platforms": "Supported Platforms",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Crear un usuario administrador",
|
||||
"cancel": "Cancelar",
|
||||
"check-metadata-step": "Comprobar fuentes de metadatos",
|
||||
"confirm-create-platforms": "RomM creará la estructura {structure} ({pattern}) con {count} plataforma{plural}. ¿Continuar?",
|
||||
"confirm-create-platforms": "RomM creará {pattern} con {count} plataforma{plural}. ¿Continuar?",
|
||||
"confirm-no-platforms": "No se detectó estructura de carpetas y no se seleccionaron plataformas. Necesitará crear la estructura de carpetas manualmente. ¿Continuar?",
|
||||
"confirm-no-structure": "No se detectó estructura de carpetas. RomM creará la estructura A (roms/{platform}) con {count} plataforma{plural}. ¿Continuar?",
|
||||
"confirm-no-structure": "No se detectó estructura de carpetas. RomM creará {pattern} con {count} plataforma{plural}. ¿Continuar?",
|
||||
"continue": "Continuar",
|
||||
"creating-platforms": "Creando carpetas…",
|
||||
"creating-platforms-failed": "Error al crear las carpetas de plataforma",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "juego",
|
||||
"games": "juegos",
|
||||
"identified": "Identificado",
|
||||
"library-structure-detected": "Estructura de biblioteca detectada",
|
||||
"library-structure-step": "Configurar estructura de biblioteca",
|
||||
"loading-library": "Inspeccionando tu biblioteca…",
|
||||
"loading-library-failed": "Error al cargar la información de la biblioteca",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Falta la clave API",
|
||||
"metadata-status-unreachable": "Inaccesible",
|
||||
"next": "Siguiente",
|
||||
"no-structure-banner-body": "RomM creará la Estructura A y añadirá las plataformas seleccionadas dentro.",
|
||||
"no-structure-banner-body": "RomM creará la estructura de la biblioteca y añadirá las plataformas seleccionadas dentro.",
|
||||
"no-structure-banner-title": "No se detectó estructura de biblioteca",
|
||||
"no-structure-detected": "No se detectó estructura - se creará la estructura A",
|
||||
"no-structure-detected": "No se detectó estructura - se creará",
|
||||
"platform": "plataforma",
|
||||
"platform-detected-with-games": "Detectada · {count} juego | Detectada · {count} juegos",
|
||||
"platform-will-create": "Se creará",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "seleccionado",
|
||||
"step-coming-soon": "Este paso se migrará pronto.",
|
||||
"step-of": "Paso {current} de {total}",
|
||||
"structure-a-detected": "Estructura A detectada",
|
||||
"structure-b-detected": "Estructura B detectada",
|
||||
"structure-banner-games": "{count} juego | {count} juegos",
|
||||
"structure-banner-platforms": "{count} plataforma | {count} plataformas",
|
||||
"supported-platforms": "Plataformas disponibles",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Créer un utilisateur administrateur",
|
||||
"cancel": "Annuler",
|
||||
"check-metadata-step": "Vérifier les sources de métadonnées",
|
||||
"confirm-create-platforms": "RomM créera la structure {structure} ({pattern}) avec {count} plateforme{plural}. Continuer?",
|
||||
"confirm-create-platforms": "RomM créera {pattern} avec {count} plateforme{plural}. Continuer?",
|
||||
"confirm-no-platforms": "Aucune structure de dossiers détectée et aucune plateforme sélectionnée. Vous devrez créer la structure de dossiers manuellement. Continuer?",
|
||||
"confirm-no-structure": "Aucune structure de dossiers détectée. RomM créera la structure A (roms/{platform}) avec {count} plateforme{plural}. Continuer?",
|
||||
"confirm-no-structure": "Aucune structure de dossiers détectée. RomM créera {pattern} avec {count} plateforme{plural}. Continuer?",
|
||||
"continue": "Continuer",
|
||||
"creating-platforms": "Création des dossiers…",
|
||||
"creating-platforms-failed": "Échec de la création des dossiers de plateformes",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "jeu",
|
||||
"games": "jeux",
|
||||
"identified": "Identifiées",
|
||||
"library-structure-detected": "Structure de bibliothèque détectée",
|
||||
"library-structure-step": "Configurer la structure de la bibliothèque",
|
||||
"loading-library": "Inspection de votre bibliothèque…",
|
||||
"loading-library-failed": "Échec du chargement des informations de la bibliothèque",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Clé API manquante",
|
||||
"metadata-status-unreachable": "Inaccessible",
|
||||
"next": "Suivant",
|
||||
"no-structure-banner-body": "RomM créera la structure A et y ajoutera les plateformes sélectionnées.",
|
||||
"no-structure-banner-body": "RomM créera la structure de la bibliothèque et y ajoutera les plateformes sélectionnées.",
|
||||
"no-structure-banner-title": "Aucune structure de bibliothèque détectée",
|
||||
"no-structure-detected": "Aucune structure détectée - la structure A sera créée",
|
||||
"no-structure-detected": "Aucune structure détectée - elle sera créée",
|
||||
"platform": "plateforme",
|
||||
"platform-detected-with-games": "Détectée · {count} jeu | Détectée · {count} jeux",
|
||||
"platform-will-create": "Sera créée",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "sélectionné",
|
||||
"step-coming-soon": "Cette étape sera migrée prochainement.",
|
||||
"step-of": "Étape {current} sur {total}",
|
||||
"structure-a-detected": "Structure A détectée",
|
||||
"structure-b-detected": "Structure B détectée",
|
||||
"structure-banner-games": "{count} jeu | {count} jeux",
|
||||
"structure-banner-platforms": "{count} plateforme | {count} plateformes",
|
||||
"supported-platforms": "Plateformes disponibles",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Rendszergazda felhasználó létrehozása",
|
||||
"cancel": "Mégse",
|
||||
"check-metadata-step": "Metaadat források ellenőrzése",
|
||||
"confirm-create-platforms": "RomM létrehozza a(z) {structure} struktúrát ({pattern}) {count} platform{plural}. Folytatás?",
|
||||
"confirm-create-platforms": "RomM létrehozza a(z) {pattern} struktúrát {count} platform{plural}. Folytatás?",
|
||||
"confirm-no-platforms": "Nem található mappastruktúra és nincsenek kiválasztott platformok. Kézzel kell létrehoznia a mappastruktúrát. Folytatás?",
|
||||
"confirm-no-structure": "Nem található mappastruktúra. RomM létrehozza az A struktúrát (roms/{platform}) {count} platform{plural}. Folytatás?",
|
||||
"confirm-no-structure": "Nem található mappastruktúra. RomM létrehozza a(z) {pattern} struktúrát {count} platform{plural}. Folytatás?",
|
||||
"continue": "Folytatás",
|
||||
"creating-platforms": "Mappák létrehozása…",
|
||||
"creating-platforms-failed": "A platform-mappák létrehozása sikertelen",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "játék",
|
||||
"games": "játékok",
|
||||
"identified": "Azonosított",
|
||||
"library-structure-detected": "Könyvtárstruktúra észlelve",
|
||||
"library-structure-step": "Könyvtárstruktúra beállítása",
|
||||
"loading-library": "Könyvtár vizsgálata…",
|
||||
"loading-library-failed": "A könyvtár adatainak betöltése sikertelen",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Hiányzik az API kulcs",
|
||||
"metadata-status-unreachable": "Nem elérhető",
|
||||
"next": "Következő",
|
||||
"no-structure-banner-body": "A RomM létrehozza az A struktúrát, és belehelyezi a kiválasztott platformokat.",
|
||||
"no-structure-banner-body": "A RomM létrehozza a könyvtárstruktúrát, és belehelyezi a kiválasztott platformokat.",
|
||||
"no-structure-banner-title": "Nem található könyvtárstruktúra",
|
||||
"no-structure-detected": "Nem található struktúra - A struktúra lesz létrehozva",
|
||||
"no-structure-detected": "Nem található struktúra - létre lesz hozva",
|
||||
"platform": "platform",
|
||||
"platform-detected-with-games": "Észlelt · {count} játék | Észlelt · {count} játék",
|
||||
"platform-will-create": "Létre lesz hozva",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "kiválasztva",
|
||||
"step-coming-soon": "Ez a lépés hamarosan átkerül.",
|
||||
"step-of": "{current}. lépés / {total}",
|
||||
"structure-a-detected": "A struktúra észlelve",
|
||||
"structure-b-detected": "B struktúra észlelve",
|
||||
"structure-banner-games": "{count} játék | {count} játék",
|
||||
"structure-banner-platforms": "{count} platform | {count} platform",
|
||||
"supported-platforms": "Elérhető platformok",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Crea un utente amministratore",
|
||||
"cancel": "Annulla",
|
||||
"check-metadata-step": "Controlla le fonti dei metadati",
|
||||
"confirm-create-platforms": "RomM creerà la struttura {structure} ({pattern}) con {count} piattaforma{plural}. Continuare?",
|
||||
"confirm-create-platforms": "RomM creerà {pattern} con {count} piattaforma{plural}. Continuare?",
|
||||
"confirm-no-platforms": "Nessuna struttura di cartelle rilevata e nessuna piattaforma selezionata. Dovrai creare manualmente la struttura delle cartelle. Continuare?",
|
||||
"confirm-no-structure": "Nessuna struttura di cartelle rilevata. RomM creerà la struttura A (roms/{platform}) con {count} piattaforma{plural}. Continuare?",
|
||||
"confirm-no-structure": "Nessuna struttura di cartelle rilevata. RomM creerà {pattern} con {count} piattaforma{plural}. Continuare?",
|
||||
"continue": "Continua",
|
||||
"creating-platforms": "Creazione cartelle in corso…",
|
||||
"creating-platforms-failed": "Impossibile creare le cartelle delle piattaforme",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "gioco",
|
||||
"games": "giochi",
|
||||
"identified": "Identificate",
|
||||
"library-structure-detected": "Struttura della libreria rilevata",
|
||||
"library-structure-step": "Configura la struttura della libreria",
|
||||
"loading-library": "Ispezione della libreria in corso…",
|
||||
"loading-library-failed": "Impossibile caricare le informazioni della libreria",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Chiave API mancante",
|
||||
"metadata-status-unreachable": "Non raggiungibile",
|
||||
"next": "Avanti",
|
||||
"no-structure-banner-body": "RomM creerà la struttura A e aggiungerà al suo interno le piattaforme selezionate.",
|
||||
"no-structure-banner-body": "RomM creerà la struttura della libreria e aggiungerà al suo interno le piattaforme selezionate.",
|
||||
"no-structure-banner-title": "Nessuna struttura di libreria rilevata",
|
||||
"no-structure-detected": "Nessuna struttura rilevata - verrà creata la struttura A",
|
||||
"no-structure-detected": "Nessuna struttura rilevata - verrà creata",
|
||||
"platform": "piattaforma",
|
||||
"platform-detected-with-games": "Rilevata · {count} gioco | Rilevata · {count} giochi",
|
||||
"platform-will-create": "Verrà creata",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "selezionato",
|
||||
"step-coming-soon": "Questo passo sarà migrato a breve.",
|
||||
"step-of": "Passo {current} di {total}",
|
||||
"structure-a-detected": "Struttura A rilevata",
|
||||
"structure-b-detected": "Struttura B rilevata",
|
||||
"structure-banner-games": "{count} gioco | {count} giochi",
|
||||
"structure-banner-platforms": "{count} piattaforma | {count} piattaforme",
|
||||
"supported-platforms": "Piattaforme disponibili",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "管理者ユーザーを作成",
|
||||
"cancel": "キャンセル",
|
||||
"check-metadata-step": "メタデータソースを確認",
|
||||
"confirm-create-platforms": "RomMは構造{structure}({pattern})を{count}プラットフォーム{plural}で作成します。続行しますか?",
|
||||
"confirm-create-platforms": "RomMは{pattern}を{count}プラットフォーム{plural}で作成します。続行しますか?",
|
||||
"confirm-no-platforms": "フォルダ構造が検出されず、プラットフォームも選択されていません。フォルダ構造を手動で作成する必要があります。続行しますか?",
|
||||
"confirm-no-structure": "フォルダ構造が検出されませんでした。RomMは構造A(roms/{platform})を{count}プラットフォーム{plural}で作成します。続行しますか?",
|
||||
"confirm-no-structure": "フォルダ構造が検出されませんでした。RomMは{pattern}を{count}プラットフォーム{plural}で作成します。続行しますか?",
|
||||
"continue": "続行",
|
||||
"creating-platforms": "フォルダを作成中…",
|
||||
"creating-platforms-failed": "プラットフォームフォルダの作成に失敗しました",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "ゲーム",
|
||||
"games": "ゲーム",
|
||||
"identified": "識別済み",
|
||||
"library-structure-detected": "ライブラリ構造が検出されました",
|
||||
"library-structure-step": "ライブラリ構造を設定",
|
||||
"loading-library": "ライブラリを確認中…",
|
||||
"loading-library-failed": "ライブラリ情報の読み込みに失敗しました",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "APIキーがありません",
|
||||
"metadata-status-unreachable": "接続不可",
|
||||
"next": "次へ",
|
||||
"no-structure-banner-body": "RomMは構造Aを作成し、選択したプラットフォームをその中に追加します。",
|
||||
"no-structure-banner-body": "RomMはライブラリ構造を作成し、選択したプラットフォームをその中に追加します。",
|
||||
"no-structure-banner-title": "ライブラリ構造が検出されませんでした",
|
||||
"no-structure-detected": "構造が検出されませんでした - 構造Aが作成されます",
|
||||
"no-structure-detected": "構造が検出されませんでした - 作成されます",
|
||||
"platform": "プラットフォーム",
|
||||
"platform-detected-with-games": "検出済み · {count}件のゲーム | 検出済み · {count}件のゲーム",
|
||||
"platform-will-create": "作成予定",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "選択済み",
|
||||
"step-coming-soon": "このステップはまもなく移行されます。",
|
||||
"step-of": "ステップ {current} / {total}",
|
||||
"structure-a-detected": "構造Aが検出されました",
|
||||
"structure-b-detected": "構造Bが検出されました",
|
||||
"structure-banner-games": "{count}件のゲーム | {count}件のゲーム",
|
||||
"structure-banner-platforms": "{count}件のプラットフォーム | {count}件のプラットフォーム",
|
||||
"supported-platforms": "利用可能なプラットフォーム",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "관리자 사용자 생성",
|
||||
"cancel": "취소",
|
||||
"check-metadata-step": "메타데이터 소스 확인",
|
||||
"confirm-create-platforms": "RomM이 구조 {structure}({pattern})를 {count}개 플랫폼{plural}으로 생성합니다. 계속하시겠습니까?",
|
||||
"confirm-create-platforms": "RomM이 {pattern}을 {count}개 플랫폼{plural}으로 생성합니다. 계속하시겠습니까?",
|
||||
"confirm-no-platforms": "폴더 구조가 감지되지 않았고 플랫폼도 선택되지 않았습니다. 폴더 구조를 수동으로 생성해야 합니다. 계속하시겠습니까?",
|
||||
"confirm-no-structure": "폴더 구조가 감지되지 않았습니다. RomM이 구조 A(roms/{platform})를 {count}개 플랫폼{plural}으로 생성합니다. 계속하시겠습니까?",
|
||||
"confirm-no-structure": "폴더 구조가 감지되지 않았습니다. RomM이 {pattern}을 {count}개 플랫폼{plural}으로 생성합니다. 계속하시겠습니까?",
|
||||
"continue": "계속",
|
||||
"creating-platforms": "폴더 생성 중…",
|
||||
"creating-platforms-failed": "플랫폼 폴더를 생성하지 못했습니다",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "게임",
|
||||
"games": "게임",
|
||||
"identified": "식별됨",
|
||||
"library-structure-detected": "라이브러리 구조가 감지됨",
|
||||
"library-structure-step": "라이브러리 구조 설정",
|
||||
"loading-library": "라이브러리 확인 중…",
|
||||
"loading-library-failed": "라이브러리 정보를 불러오지 못했습니다",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API 키 없음",
|
||||
"metadata-status-unreachable": "연결할 수 없음",
|
||||
"next": "다음",
|
||||
"no-structure-banner-body": "RomM이 구조 A를 만들고 선택한 플랫폼을 그 안에 추가합니다.",
|
||||
"no-structure-banner-body": "RomM이 라이브러리 구조를 만들고 선택한 플랫폼을 그 안에 추가합니다.",
|
||||
"no-structure-banner-title": "라이브러리 구조가 감지되지 않았습니다",
|
||||
"no-structure-detected": "구조가 감지되지 않음 - 구조 A가 생성됩니다",
|
||||
"no-structure-detected": "구조가 감지되지 않음 - 생성됩니다",
|
||||
"platform": "플랫폼",
|
||||
"platform-detected-with-games": "감지됨 · {count}개 게임 | 감지됨 · {count}개 게임",
|
||||
"platform-will-create": "생성 예정",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "선택됨",
|
||||
"step-coming-soon": "이 단계는 곧 마이그레이션됩니다.",
|
||||
"step-of": "{total}단계 중 {current}",
|
||||
"structure-a-detected": "구조 A가 감지됨",
|
||||
"structure-b-detected": "구조 B가 감지됨",
|
||||
"structure-banner-games": "{count}개 게임 | {count}개 게임",
|
||||
"structure-banner-platforms": "{count}개 플랫폼 | {count}개 플랫폼",
|
||||
"supported-platforms": "사용 가능한 플랫폼",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Utwórz użytkownika administratora",
|
||||
"cancel": "Anuluj",
|
||||
"check-metadata-step": "Sprawdź źródła metadanych",
|
||||
"confirm-create-platforms": "RomM utworzy strukturę {structure} ({pattern}) z {count} platforma{plural}. Kontynuować?",
|
||||
"confirm-create-platforms": "RomM utworzy {pattern} z {count} platforma{plural}. Kontynuować?",
|
||||
"confirm-no-platforms": "Nie wykryto struktury folderów i nie wybrano żadnych platform. Będziesz musiał ręcznie utworzyć strukturę folderów. Kontynuować?",
|
||||
"confirm-no-structure": "Nie wykryto struktury folderów. RomM utworzy strukturę A (roms/{platform}) z {count} platforma{plural}. Kontynuować?",
|
||||
"confirm-no-structure": "Nie wykryto struktury folderów. RomM utworzy {pattern} z {count} platforma{plural}. Kontynuować?",
|
||||
"continue": "Kontynuuj",
|
||||
"creating-platforms": "Tworzenie folderów…",
|
||||
"creating-platforms-failed": "Nie udało się utworzyć folderów platform",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "gra",
|
||||
"games": "gry",
|
||||
"identified": "Zidentyfikowane",
|
||||
"library-structure-detected": "Wykryto strukturę biblioteki",
|
||||
"library-structure-step": "Skonfiguruj strukturę biblioteki",
|
||||
"loading-library": "Sprawdzanie twojej biblioteki…",
|
||||
"loading-library-failed": "Nie udało się załadować informacji o bibliotece",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Brak klucza API",
|
||||
"metadata-status-unreachable": "Niedostępne",
|
||||
"next": "Dalej",
|
||||
"no-structure-banner-body": "RomM utworzy Strukturę A i doda wewnątrz wybrane platformy.",
|
||||
"no-structure-banner-body": "RomM utworzy strukturę biblioteki i doda wewnątrz wybrane platformy.",
|
||||
"no-structure-banner-title": "Nie wykryto struktury biblioteki",
|
||||
"no-structure-detected": "Nie wykryto struktury - zostanie utworzona struktura A",
|
||||
"no-structure-detected": "Nie wykryto struktury - zostanie utworzona",
|
||||
"platform": "platforma",
|
||||
"platform-detected-with-games": "Wykryto · {count} gra | Wykryto · {count} gry | Wykryto · {count} gier",
|
||||
"platform-will-create": "Zostanie utworzony",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "wybrano",
|
||||
"step-coming-soon": "Ten krok zostanie wkrótce przeniesiony.",
|
||||
"step-of": "Krok {current} z {total}",
|
||||
"structure-a-detected": "Wykryto strukturę A",
|
||||
"structure-b-detected": "Wykryto strukturę B",
|
||||
"structure-banner-games": "{count} gra | {count} gry | {count} gier",
|
||||
"structure-banner-platforms": "{count} platforma | {count} platformy | {count} platform",
|
||||
"supported-platforms": "Dostępne platformy",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Criar um usuário administrador",
|
||||
"cancel": "Cancelar",
|
||||
"check-metadata-step": "Verificar fontes de metadados",
|
||||
"confirm-create-platforms": "RomM criará a estrutura {structure} ({pattern}) com {count} plataforma{plural}. Continuar?",
|
||||
"confirm-create-platforms": "RomM criará {pattern} com {count} plataforma{plural}. Continuar?",
|
||||
"confirm-no-platforms": "Nenhuma estrutura de pasta detectada e nenhuma plataforma selecionada. Você precisará criar a estrutura de pastas manualmente. Continuar?",
|
||||
"confirm-no-structure": "Nenhuma estrutura de pasta detectada. RomM criará a estrutura A (roms/{platform}) com {count} plataforma{plural}. Continuar?",
|
||||
"confirm-no-structure": "Nenhuma estrutura de pasta detectada. RomM criará {pattern} com {count} plataforma{plural}. Continuar?",
|
||||
"continue": "Continuar",
|
||||
"creating-platforms": "Criando pastas…",
|
||||
"creating-platforms-failed": "Falha ao criar pastas de plataformas",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "jogo",
|
||||
"games": "jogos",
|
||||
"identified": "Identificado",
|
||||
"library-structure-detected": "Estrutura de biblioteca detectada",
|
||||
"library-structure-step": "Configurar estrutura da biblioteca",
|
||||
"loading-library": "Inspecionando sua biblioteca…",
|
||||
"loading-library-failed": "Falha ao carregar informações da biblioteca",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Chave de API ausente",
|
||||
"metadata-status-unreachable": "Inacessível",
|
||||
"next": "Próximo",
|
||||
"no-structure-banner-body": "O RomM criará a Estrutura A e adicionará as plataformas selecionadas dentro.",
|
||||
"no-structure-banner-body": "O RomM criará a estrutura da biblioteca e adicionará as plataformas selecionadas dentro.",
|
||||
"no-structure-banner-title": "Nenhuma estrutura de biblioteca detectada",
|
||||
"no-structure-detected": "Nenhuma estrutura detectada - a estrutura A será criada",
|
||||
"no-structure-detected": "Nenhuma estrutura detectada - ela será criada",
|
||||
"platform": "plataforma",
|
||||
"platform-detected-with-games": "Detectada · {count} jogo | Detectada · {count} jogos",
|
||||
"platform-will-create": "Será criada",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "selecionado",
|
||||
"step-coming-soon": "Esta etapa será migrada em breve.",
|
||||
"step-of": "Etapa {current} de {total}",
|
||||
"structure-a-detected": "Estrutura A detectada",
|
||||
"structure-b-detected": "Estrutura B detectada",
|
||||
"structure-banner-games": "{count} jogo | {count} jogos",
|
||||
"structure-banner-platforms": "{count} plataforma | {count} plataformas",
|
||||
"supported-platforms": "Plataformas disponíveis",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Creează un utilizator administrator",
|
||||
"cancel": "Anulează",
|
||||
"check-metadata-step": "Verifică sursele de metadate",
|
||||
"confirm-create-platforms": "RomM va crea structura {structure} ({pattern}) cu {count} platformă{plural}. Continuă?",
|
||||
"confirm-create-platforms": "RomM va crea {pattern} cu {count} platformă{plural}. Continuă?",
|
||||
"confirm-no-platforms": "Nu s-a detectat nicio structură de directoare și nu au fost selectate platforme. Va trebui să creezi manual structura directoarelor. Continuă?",
|
||||
"confirm-no-structure": "Nu s-a detectat nicio structură de directoare. RomM va crea structura A (roms/{platform}) cu {count} platformă{plural}. Continuă?",
|
||||
"confirm-no-structure": "Nu s-a detectat nicio structură de directoare. RomM va crea {pattern} cu {count} platformă{plural}. Continuă?",
|
||||
"continue": "Continuă",
|
||||
"creating-platforms": "Se creează folderele…",
|
||||
"creating-platforms-failed": "Crearea folderelor de platforme a eșuat",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "joc",
|
||||
"games": "jocuri",
|
||||
"identified": "Identificat",
|
||||
"library-structure-detected": "Structură de bibliotecă detectată",
|
||||
"library-structure-step": "Configurează structura bibliotecii",
|
||||
"loading-library": "Se inspectează biblioteca…",
|
||||
"loading-library-failed": "Informațiile bibliotecii nu au putut fi încărcate",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "Cheie API lipsă",
|
||||
"metadata-status-unreachable": "Inaccesibil",
|
||||
"next": "Următorul",
|
||||
"no-structure-banner-body": "RomM va crea structura A și va adăuga platformele selectate înăuntru.",
|
||||
"no-structure-banner-body": "RomM va crea structura bibliotecii și va adăuga platformele selectate înăuntru.",
|
||||
"no-structure-banner-title": "Nicio structură de bibliotecă detectată",
|
||||
"no-structure-detected": "Nu s-a detectat nicio structură - se va crea structura A",
|
||||
"no-structure-detected": "Nu s-a detectat nicio structură - va fi creată",
|
||||
"platform": "platformă",
|
||||
"platform-detected-with-games": "Detectat · {count} joc | Detectat · {count} jocuri",
|
||||
"platform-will-create": "Va fi creat",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "selectat",
|
||||
"step-coming-soon": "Acest pas va fi migrat în curând.",
|
||||
"step-of": "Pasul {current} din {total}",
|
||||
"structure-a-detected": "Structura A detectată",
|
||||
"structure-b-detected": "Structura B detectată",
|
||||
"structure-banner-games": "{count} joc | {count} jocuri",
|
||||
"structure-banner-platforms": "{count} platformă | {count} platforme",
|
||||
"supported-platforms": "Platforme disponibile",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Создать пользователя-администратора",
|
||||
"cancel": "Отмена",
|
||||
"check-metadata-step": "Проверить источники метаданных",
|
||||
"confirm-create-platforms": "RomM создаст структуру {structure} ({pattern}) с {count} платформ{plural}. Продолжить?",
|
||||
"confirm-create-platforms": "RomM создаст {pattern} с {count} платформ{plural}. Продолжить?",
|
||||
"confirm-no-platforms": "Структура папок не обнаружена и платформы не выбраны. Вам нужно будет создать структуру папок вручную. Продолжить?",
|
||||
"confirm-no-structure": "Структура папок не обнаружена. RomM создаст структуру A (roms/{platform}) с {count} платформ{plural}. Продолжить?",
|
||||
"confirm-no-structure": "Структура папок не обнаружена. RomM создаст {pattern} с {count} платформ{plural}. Продолжить?",
|
||||
"continue": "Продолжить",
|
||||
"creating-platforms": "Создание папок…",
|
||||
"creating-platforms-failed": "Не удалось создать папки платформ",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "игра",
|
||||
"games": "игры",
|
||||
"identified": "Опознано",
|
||||
"library-structure-detected": "Обнаружена структура библиотеки",
|
||||
"library-structure-step": "Настроить структуру библиотеки",
|
||||
"loading-library": "Анализ вашей библиотеки…",
|
||||
"loading-library-failed": "Не удалось загрузить информацию о библиотеке",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API-ключ отсутствует",
|
||||
"metadata-status-unreachable": "Недоступно",
|
||||
"next": "Далее",
|
||||
"no-structure-banner-body": "RomM создаст структуру А и добавит выбранные платформы внутрь.",
|
||||
"no-structure-banner-body": "RomM создаст структуру библиотеки и добавит выбранные платформы внутрь.",
|
||||
"no-structure-banner-title": "Структура библиотеки не обнаружена",
|
||||
"no-structure-detected": "Структура не обнаружена - будет создана структура A",
|
||||
"no-structure-detected": "Структура не обнаружена - она будет создана",
|
||||
"platform": "платформа",
|
||||
"platform-detected-with-games": "Обнаружено · {count} игра | Обнаружено · {count} игр",
|
||||
"platform-will-create": "Будет создано",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "выбрано",
|
||||
"step-coming-soon": "Этот шаг будет перенесён в ближайшее время.",
|
||||
"step-of": "Шаг {current} из {total}",
|
||||
"structure-a-detected": "Обнаружена структура A",
|
||||
"structure-b-detected": "Обнаружена структура B",
|
||||
"structure-banner-games": "{count} игра | {count} игр",
|
||||
"structure-banner-platforms": "{count} платформа | {count} платформ",
|
||||
"supported-platforms": "Доступные платформы",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "Yönetici kullanıcı oluştur",
|
||||
"cancel": "İptal",
|
||||
"check-metadata-step": "Meta veri kaynaklarını kontrol et",
|
||||
"confirm-create-platforms": "RomM, {count} platform{plural} ile {structure} ({pattern}) yapısını oluşturacak. Devam edilsin mi?",
|
||||
"confirm-create-platforms": "RomM, {count} platform{plural} ile {pattern} oluşturacak. Devam edilsin mi?",
|
||||
"confirm-no-platforms": "Klasör yapısı algılanamadı ve platform seçilmedi. Klasör yapısını manuel olarak oluşturmanız gerekecek. Devam edilsin mi?",
|
||||
"confirm-no-structure": "Klasör yapısı algılanamadı. RomM, {count} platform{plural} ile A Yapısı (roms/{platform}) oluşturacak. Devam edilsin mi?",
|
||||
"confirm-no-structure": "Klasör yapısı algılanamadı. RomM, {count} platform{plural} ile {pattern} oluşturacak. Devam edilsin mi?",
|
||||
"continue": "Devam et",
|
||||
"creating-platforms": "Klasörler oluşturuluyor…",
|
||||
"creating-platforms-failed": "Platform klasörleri oluşturulamadı",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "oyun",
|
||||
"games": "oyun",
|
||||
"identified": "Tanımlandı",
|
||||
"library-structure-detected": "Kütüphane yapısı algılandı",
|
||||
"library-structure-step": "Kütüphane yapısını ayarla",
|
||||
"loading-library": "Kütüphane inceleniyor…",
|
||||
"loading-library-failed": "Kütüphane bilgisi yüklenemedi",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API anahtarı eksik",
|
||||
"metadata-status-unreachable": "Erişilemiyor",
|
||||
"next": "İleri",
|
||||
"no-structure-banner-body": "RomM, A Yapısı oluşturacak ve seçili platformları içine ekleyecek.",
|
||||
"no-structure-banner-body": "RomM, kütüphane yapısını oluşturacak ve seçili platformları içine ekleyecek.",
|
||||
"no-structure-banner-title": "Kütüphane yapısı algılanamadı",
|
||||
"no-structure-detected": "Yapı algılanamadı - A Yapısı oluşturulacak",
|
||||
"no-structure-detected": "Yapı algılanamadı - oluşturulacak",
|
||||
"platform": "platform",
|
||||
"platform-detected-with-games": "Algılandı · {count} oyun | Algılandı · {count} oyun",
|
||||
"platform-will-create": "Oluşturulacak",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "seçildi",
|
||||
"step-coming-soon": "Bu adım yakında taşınacak.",
|
||||
"step-of": "Adım {current} / {total}",
|
||||
"structure-a-detected": "A Yapısı algılandı",
|
||||
"structure-b-detected": "B Yapısı algılandı",
|
||||
"structure-banner-games": "{count} oyun | {count} oyun",
|
||||
"structure-banner-platforms": "{count} platform | {count} platform",
|
||||
"supported-platforms": "Desteklenen Platformlar",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "创建管理员用户",
|
||||
"cancel": "取消",
|
||||
"check-metadata-step": "检查元数据源",
|
||||
"confirm-create-platforms": "RomM 将创建结构 {structure}({pattern})包含 {count} 个平台{plural}。继续吗?",
|
||||
"confirm-create-platforms": "RomM 将创建 {pattern} 包含 {count} 个平台{plural}。继续吗?",
|
||||
"confirm-no-platforms": "未检测到文件夹结构且未选择平台。您需要手动创建文件夹结构。继续吗?",
|
||||
"confirm-no-structure": "未检测到文件夹结构。RomM 将创建结构 A(roms/{platform})包含 {count} 个平台{plural}。继续吗?",
|
||||
"confirm-no-structure": "未检测到文件夹结构。RomM 将创建 {pattern} 包含 {count} 个平台{plural}。继续吗?",
|
||||
"continue": "继续",
|
||||
"creating-platforms": "正在创建文件夹…",
|
||||
"creating-platforms-failed": "创建平台文件夹失败",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "游戏",
|
||||
"games": "游戏",
|
||||
"identified": "已识别",
|
||||
"library-structure-detected": "检测到游戏库结构",
|
||||
"library-structure-step": "设置库结构",
|
||||
"loading-library": "正在检查您的游戏库…",
|
||||
"loading-library-failed": "加载游戏库信息失败",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "API 密钥缺失",
|
||||
"metadata-status-unreachable": "无法访问",
|
||||
"next": "下一步",
|
||||
"no-structure-banner-body": "RomM 将创建结构 A,并将所选平台添加到其中。",
|
||||
"no-structure-banner-body": "RomM 将创建游戏库结构,并将所选平台添加到其中。",
|
||||
"no-structure-banner-title": "未检测到游戏库结构",
|
||||
"no-structure-detected": "未检测到结构 - 将创建结构 A",
|
||||
"no-structure-detected": "未检测到结构 - 将创建结构",
|
||||
"platform": "平台",
|
||||
"platform-detected-with-games": "已检测到 · {count} 个游戏 | 已检测到 · {count} 个游戏",
|
||||
"platform-will-create": "将创建",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "已选择",
|
||||
"step-coming-soon": "此步骤将很快迁移。",
|
||||
"step-of": "步骤 {current} / {total}",
|
||||
"structure-a-detected": "检测到结构 A",
|
||||
"structure-b-detected": "检测到结构 B",
|
||||
"structure-banner-games": "{count} 个游戏 | {count} 个游戏",
|
||||
"structure-banner-platforms": "{count} 个平台 | {count} 个平台",
|
||||
"supported-platforms": "可用平台",
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"admin-user-step": "建立管理員使用者",
|
||||
"cancel": "取消",
|
||||
"check-metadata-step": "檢查詮釋資料來源",
|
||||
"confirm-create-platforms": "RomM 將建立結構 {structure}({pattern})包含 {count} 個平台{plural}。繼續嗎?",
|
||||
"confirm-create-platforms": "RomM 將建立 {pattern} 包含 {count} 個平台{plural}。繼續嗎?",
|
||||
"confirm-no-platforms": "未偵測到資料夾結構且未選擇平台。您需要手動建立資料夾結構。繼續嗎?",
|
||||
"confirm-no-structure": "未偵測到資料夾結構。RomM 將建立結構 A(roms/{platform})包含 {count} 個平台{plural}。繼續嗎?",
|
||||
"confirm-no-structure": "未偵測到資料夾結構。RomM 將建立 {pattern} 包含 {count} 個平台{plural}。繼續嗎?",
|
||||
"continue": "繼續",
|
||||
"creating-platforms": "正在建立資料夾…",
|
||||
"creating-platforms-failed": "建立平台資料夾失敗",
|
||||
@@ -26,6 +26,7 @@
|
||||
"game": "遊戲",
|
||||
"games": "遊戲",
|
||||
"identified": "已識別",
|
||||
"library-structure-detected": "偵測到遊戲庫結構",
|
||||
"library-structure-step": "設定資料庫結構",
|
||||
"loading-library": "正在檢查您的遊戲庫…",
|
||||
"loading-library-failed": "載入遊戲庫資訊失敗",
|
||||
@@ -44,9 +45,9 @@
|
||||
"metadata-status-key-missing": "缺少 API 金鑰",
|
||||
"metadata-status-unreachable": "無法連線",
|
||||
"next": "下一步",
|
||||
"no-structure-banner-body": "RomM 將建立結構 A,並將所選平台加入其中。",
|
||||
"no-structure-banner-body": "RomM 將建立遊戲庫結構,並將所選平台加入其中。",
|
||||
"no-structure-banner-title": "未偵測到遊戲庫結構",
|
||||
"no-structure-detected": "未偵測到結構 - 將建立結構 A",
|
||||
"no-structure-detected": "未偵測到結構 - 將建立結構",
|
||||
"platform": "平台",
|
||||
"platform-detected-with-games": "已偵測 · {count} 個遊戲 | 已偵測 · {count} 個遊戲",
|
||||
"platform-will-create": "將建立",
|
||||
@@ -99,8 +100,6 @@
|
||||
"selected": "已選擇",
|
||||
"step-coming-soon": "此步驟即將遷移。",
|
||||
"step-of": "步驟 {current} / {total}",
|
||||
"structure-a-detected": "偵測到結構 A",
|
||||
"structure-b-detected": "偵測到結構 B",
|
||||
"structure-banner-games": "{count} 個遊戲 | {count} 個遊戲",
|
||||
"structure-banner-platforms": "{count} 個平台 | {count} 個平台",
|
||||
"supported-platforms": "可用平台",
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import api from "@/services/api";
|
||||
import type { Platform } from "@/stores/platforms";
|
||||
|
||||
export type LibraryStructure = "struct_a" | "struct_b" | null;
|
||||
|
||||
export interface ExistingPlatform {
|
||||
fs_slug: string;
|
||||
rom_count: number;
|
||||
}
|
||||
|
||||
export interface SetupLibraryInfo {
|
||||
detected_structure: LibraryStructure;
|
||||
library_ready: boolean;
|
||||
library_structure: string;
|
||||
existing_platforms: ExistingPlatform[];
|
||||
supported_platforms: Platform[];
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ const supportedSlugSet = computed(
|
||||
|
||||
const detectedPlatforms = computed<Array<Platform & { unidentified: boolean }>>(
|
||||
() => {
|
||||
if (!props.libraryInfo.detected_structure) return [];
|
||||
if (!props.libraryInfo.library_ready) return [];
|
||||
const identified = props.libraryInfo.supported_platforms
|
||||
.filter((p) => detectedSlugSet.value.has(p.fs_slug))
|
||||
.map((p) => ({ ...p, unidentified: false }));
|
||||
@@ -303,11 +303,8 @@ function setGroupOpen(key: string, open: boolean) {
|
||||
|
||||
// ── Structure banner copy ──────────────────────────────────────────
|
||||
|
||||
const detectedStructure = computed(() => props.libraryInfo.detected_structure);
|
||||
const structurePattern = computed(() => {
|
||||
if (detectedStructure.value === "struct_b") return "{platform}/roms";
|
||||
return "roms/{platform}";
|
||||
});
|
||||
const libraryReady = computed(() => props.libraryInfo.library_ready);
|
||||
const structurePattern = computed(() => props.libraryInfo.library_structure);
|
||||
const detectedPlatformCount = computed(
|
||||
() => props.libraryInfo.existing_platforms.length,
|
||||
);
|
||||
@@ -322,22 +319,20 @@ const detectedPlatformCount = computed(
|
||||
|
||||
<div
|
||||
class="r-setup-platforms__banner"
|
||||
:data-tone="detectedStructure ? 'info' : 'warning'"
|
||||
:data-tone="libraryReady ? 'info' : 'warning'"
|
||||
>
|
||||
<div class="r-setup-platforms__banner-text">
|
||||
<strong>
|
||||
{{
|
||||
detectedStructure === "struct_a"
|
||||
? t("setup.structure-a-detected")
|
||||
: detectedStructure === "struct_b"
|
||||
? t("setup.structure-b-detected")
|
||||
: t("setup.no-structure-banner-title")
|
||||
libraryReady
|
||||
? t("setup.library-structure-detected")
|
||||
: t("setup.no-structure-banner-title")
|
||||
}}
|
||||
</strong>
|
||||
<code class="r-setup-platforms__banner-pattern">
|
||||
{{ structurePattern }}
|
||||
</code>
|
||||
<span v-if="!detectedStructure" class="r-setup-platforms__banner-meta">
|
||||
<span v-if="!libraryReady" class="r-setup-platforms__banner-meta">
|
||||
— {{ t("setup.no-structure-banner-body") }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -38,7 +38,8 @@ const stepDirection = ref<"forward" | "back">("forward");
|
||||
|
||||
// Step 1 — library + platforms
|
||||
const EMPTY_LIBRARY_INFO: SetupLibraryInfo = {
|
||||
detected_structure: null,
|
||||
library_ready: false,
|
||||
library_structure: "",
|
||||
existing_platforms: [],
|
||||
supported_platforms: [],
|
||||
};
|
||||
|
||||
@@ -194,7 +194,7 @@ describe("Home", () => {
|
||||
setActivePinia(createPinia());
|
||||
getLibraryInfo.mockReset();
|
||||
getLibraryInfo.mockResolvedValue({
|
||||
data: { detected_structure: "struct_a", existing_platforms: [] },
|
||||
data: { library_ready: true, existing_platforms: [] },
|
||||
});
|
||||
getRecommendedRoms.mockReset();
|
||||
getRecommendedRoms.mockResolvedValue({ data: [] });
|
||||
|
||||
@@ -156,8 +156,8 @@ const groupPlatformsByManufacturer = (platforms: Platform[]) => {
|
||||
const groupedExistingPlatforms = computed(() => {
|
||||
if (!libraryInfo.value) return [];
|
||||
|
||||
// Only show existing platforms if a structure was actually detected
|
||||
if (!libraryInfo.value.detected_structure) return [];
|
||||
// Only show existing platforms once the library folder actually exists
|
||||
if (!libraryInfo.value.library_ready) return [];
|
||||
|
||||
// Get supported platform slugs for quick lookup
|
||||
const supportedSlugs = new Set(
|
||||
@@ -219,8 +219,8 @@ const groupedAvailablePlatforms = computed(() => {
|
||||
|
||||
// Check if there are existing platforms
|
||||
const hasExistingPlatforms = computed(() => {
|
||||
// Only consider platforms as existing if a structure was detected
|
||||
if (!libraryInfo.value?.detected_structure) return false;
|
||||
// Only consider platforms as existing once the library folder exists
|
||||
if (!libraryInfo.value?.library_ready) return false;
|
||||
return (libraryInfo.value?.existing_platforms.length ?? 0) > 0;
|
||||
});
|
||||
|
||||
@@ -310,7 +310,7 @@ function handleNext(nextCallback: () => void) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hasStructure = libraryInfo.value?.detected_structure;
|
||||
const hasStructure = libraryInfo.value?.library_ready;
|
||||
const platformsToCreate = selectedPlatforms.value.filter(
|
||||
(slug) => !isPlatformExisting(slug),
|
||||
);
|
||||
@@ -318,6 +318,7 @@ function handleNext(nextCallback: () => void) {
|
||||
// Case 1: No structure detected and user is creating platforms
|
||||
if (!hasStructure && platformsToCreate.length > 0) {
|
||||
confirmDialogMessage.value = t("setup.confirm-no-structure", {
|
||||
pattern: libraryInfo.value?.library_structure ?? "",
|
||||
count: platformsToCreate.length,
|
||||
plural: platformsToCreate.length > 1 ? "s" : "",
|
||||
});
|
||||
@@ -336,13 +337,8 @@ function handleNext(nextCallback: () => void) {
|
||||
|
||||
// Case 3: Structure is detected and user selected at least one platform to create
|
||||
if (hasStructure && platformsToCreate.length > 0 && libraryInfo.value) {
|
||||
const structurePattern =
|
||||
libraryInfo.value.detected_structure === "struct_a"
|
||||
? "roms/{platform}"
|
||||
: "{platform}/roms";
|
||||
confirmDialogMessage.value = t("setup.confirm-create-platforms", {
|
||||
structure: libraryInfo.value.detected_structure,
|
||||
pattern: structurePattern,
|
||||
pattern: libraryInfo.value.library_structure,
|
||||
count: platformsToCreate.length,
|
||||
plural: platformsToCreate.length > 1 ? "s" : "",
|
||||
});
|
||||
@@ -526,20 +522,13 @@ onMounted(() => {
|
||||
<p>
|
||||
<strong>{{ t("setup.folder-structure") }}:</strong>
|
||||
{{
|
||||
libraryInfo?.detected_structure === "struct_a"
|
||||
? t("setup.structure-a-detected")
|
||||
: libraryInfo?.detected_structure === "struct_b"
|
||||
? t("setup.structure-b-detected")
|
||||
: t("setup.no-structure-detected")
|
||||
libraryInfo?.library_ready
|
||||
? t("setup.library-structure-detected")
|
||||
: t("setup.no-structure-detected")
|
||||
}}
|
||||
</p>
|
||||
<p class="text-caption text-grey">
|
||||
{{
|
||||
libraryInfo?.detected_structure === "struct_a" ||
|
||||
!libraryInfo?.detected_structure
|
||||
? "roms/{platform}"
|
||||
: "{platform}/roms"
|
||||
}}
|
||||
{{ libraryInfo?.library_structure }}
|
||||
</p>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
Reference in New Issue
Block a user