mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
fix: keep save and content files out of the truth
This commit is contained in:
1 parent
29e2e13d65
commit
c1b930a6fd
6 files changed
+48
-10
No files matched your search
@@ -31,6 +31,7 @@ from common import (
|
||||
require_yaml,
|
||||
runs_standalone,
|
||||
)
|
||||
from validation import read_from_system_dir
|
||||
|
||||
yaml = require_yaml()
|
||||
|
||||
@@ -332,9 +333,7 @@ def _cross_reference_profile(
|
||||
if file_mode == "libretro" and is_standalone:
|
||||
continue
|
||||
|
||||
# Skip files loaded from non-system directories (save_dir, content_dir)
|
||||
load_from = f.get("load_from", "")
|
||||
if load_from and load_from != "system_dir":
|
||||
if not read_from_system_dir(f):
|
||||
continue
|
||||
|
||||
# Skip filename-agnostic files (handled by agnostic scan)
|
||||
|
||||
@@ -14,6 +14,7 @@ from common import resolve_local_file
|
||||
from common import runs_standalone
|
||||
from common import sanitize_pack_path
|
||||
from common import size_fits
|
||||
from validation import read_from_system_dir
|
||||
def _emulator_systems_index(emu_profiles: dict | None) -> dict[str, list[str]]:
|
||||
"""Map both the profile key and its display name to the profile's systems.
|
||||
|
||||
@@ -564,9 +565,7 @@ def _collect_emulator_extras(
|
||||
continue
|
||||
if file_mode == "libretro" and is_standalone:
|
||||
continue
|
||||
# Skip files loaded from non-system directories (save_dir, content_dir)
|
||||
load_from = f.get("load_from", "")
|
||||
if load_from and load_from != "system_dir":
|
||||
if not read_from_system_dir(f):
|
||||
continue
|
||||
if is_standalone:
|
||||
raw = f.get("standalone_path") or f.get("path") or fname
|
||||
|
||||
+3
-1
@@ -9,7 +9,7 @@ from __future__ import annotations
|
||||
import sys
|
||||
|
||||
from common import _norm_system_id, resolve_platform_cores, runs_standalone
|
||||
from validation import filter_files_by_mode
|
||||
from validation import filter_files_by_mode, read_from_system_dir
|
||||
|
||||
|
||||
def _serialize_source_ref(sr: object) -> str:
|
||||
@@ -378,6 +378,8 @@ def generate_platform_truth(
|
||||
)
|
||||
|
||||
for fe in filtered:
|
||||
if not read_from_system_dir(fe):
|
||||
continue
|
||||
profile_sid = fe.get("system", "")
|
||||
if not profile_sid:
|
||||
sys_ids = profile.get("systems", [])
|
||||
|
||||
@@ -313,6 +313,17 @@ def validate_cli_modes(args, mode_attrs: list[str]) -> None:
|
||||
raise SystemExit(f"Options are mutually exclusive: --{' --'.join(mode_attrs)}")
|
||||
|
||||
|
||||
def read_from_system_dir(file_entry: dict) -> bool:
|
||||
"""Whether the emulator reads this entry from the system directory.
|
||||
|
||||
A file loaded from the save, content or working directory is not a BIOS:
|
||||
no platform lists it, no pack carries it, and the truth model must not
|
||||
ask a platform to declare it.
|
||||
"""
|
||||
load_from = file_entry.get("load_from", "")
|
||||
return not load_from or load_from == "system_dir"
|
||||
|
||||
|
||||
def filter_files_by_mode(files: list[dict], standalone: bool) -> list[dict]:
|
||||
"""Filter file entries by libretro/standalone mode."""
|
||||
result = []
|
||||
|
||||
+2
-3
@@ -79,6 +79,7 @@ from validation import (
|
||||
check_file_validation,
|
||||
filter_files_by_mode,
|
||||
find_validated_variant,
|
||||
read_from_system_dir,
|
||||
)
|
||||
|
||||
DEFAULT_DB = "database.json"
|
||||
@@ -404,9 +405,7 @@ def _candidate_verdict(
|
||||
return "skip"
|
||||
if file_mode == "libretro" and is_standalone:
|
||||
return "skip"
|
||||
# Read from somewhere other than the system directory: not a BIOS gap.
|
||||
load_from = file_entry.get("load_from", "")
|
||||
if load_from and load_from != "system_dir":
|
||||
if not read_from_system_dir(file_entry):
|
||||
return "skip"
|
||||
# Filename-agnostic entries are answered by the builder's own scan.
|
||||
if file_entry.get("agnostic"):
|
||||
|
||||
@@ -197,5 +197,33 @@ class RenameMatching(unittest.TestCase):
|
||||
self.assertNotIn("lonely.bin", matched_truth)
|
||||
|
||||
|
||||
|
||||
class OnlySystemDirectoryEntries(unittest.TestCase):
|
||||
"""The truth kept files read from the save, content or working directory:
|
||||
diff_truth listed Cemu's mlc01 certificates, panda3ds's seeddb.bin and
|
||||
neo-emu's neogeo.zip as missing from platform lists that the pack and
|
||||
verify deliberately leave them out of."""
|
||||
|
||||
def test_a_file_read_elsewhere_is_not_asked_of_the_platform(self):
|
||||
from truth import generate_platform_truth
|
||||
|
||||
profiles = {
|
||||
"core": {
|
||||
"emulator": "Core",
|
||||
"type": "libretro",
|
||||
"systems": ["sys"],
|
||||
"files": [
|
||||
{"name": "bios.bin", "sha1": "a" * 40},
|
||||
{"name": "explicit.bin", "sha1": "b" * 40, "load_from": "system_dir"},
|
||||
{"name": "cert.der", "sha1": "c" * 40, "load_from": "save_dir"},
|
||||
{"name": "game.zip", "sha1": "d" * 40, "load_from": "content_dir"},
|
||||
],
|
||||
}
|
||||
}
|
||||
result = generate_platform_truth("p", {"cores": ["core"]}, {}, profiles)
|
||||
names = sorted(f["name"] for f in result["systems"]["sys"]["files"])
|
||||
self.assertEqual(names, ["bios.bin", "explicit.bin"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user