refactor: test an entry's build in read_by_build

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:01:18 +01:00
1 parent fd3d93a93f
commit c8270b5361
4 files changed
+14 -26

No files matched your search

+2 -3
View File
@@ -2,7 +2,7 @@
from __future__ import annotations
from resolve.validation import read_by_build
_directory_members_cache: dict[int, tuple[dict, dict[str, dict[str, str]]]] = {}
@@ -78,10 +78,9 @@ def expand_directory_entries(
# A file the profile names itself is left to that entry, in the same
# build and below the same root: MAME's libretro floppy samples share
# their path with the standalone tree RetroPie reads below roms/.
other_build = "libretro" if standalone else "standalone"
named = {
(entry.get("root") or "", destination(entry)) for entry in files
if entry.get("type") != "directory" and entry.get("mode") != other_build
if entry.get("type") != "directory" and read_by_build(entry, standalone)
}
expanded: list[dict] = []
for entry in files:
+7 -13
View File
@@ -656,10 +656,7 @@ def outside_gap_scope(file_entry: dict, is_standalone: bool) -> bool:
return True
if "path" in file_entry and file_entry["path"] is None:
return True
mode = file_entry.get("mode")
if (mode == "standalone" and not is_standalone) or (
mode == "libretro" and is_standalone
):
if not read_by_build(file_entry, is_standalone):
return True
return not (
read_from_system_dir(file_entry, is_standalone)
@@ -779,17 +776,14 @@ def opens_by_name(file_entry: dict, profile: dict, standalone: bool = False) ->
return True
def read_by_build(entry: dict, standalone: bool) -> bool:
"""Whether the build that runs (standalone or libretro) reads the entry."""
return entry.get("mode") != ("libretro" if standalone else "standalone")
def filter_files_by_mode(files: list[dict], standalone: bool) -> list[dict]:
"""Filter file entries by libretro/standalone mode."""
result = []
for f in files:
fmode = f.get("mode", "")
if standalone and fmode == "libretro":
continue
if not standalone and fmode == "standalone":
continue
result.append(f)
return result
return [f for f in files if read_by_build(f, standalone)]
def installed_with_emulator(entry: dict, platform: str = "") -> bool: