mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 09:23:26 -05:00
fix: refuse a data key the platform does not use
Under --key the platform restriction was not applied, so dolphin-sys was downloaded again for RomM, which never reads it. A key whose platforms exclude the one named is now refused.
This commit is contained in:
1 parent
32d32e5718
commit
999a77a96a
2 files changed
+26
No files matched your search
@@ -544,6 +544,15 @@ def main() -> None:
|
||||
if args.key not in registry:
|
||||
log.error("unknown key: %s (available: %s)", args.key, ", ".join(registry))
|
||||
raise SystemExit(1)
|
||||
allowed = registry[args.key].get("for_platforms")
|
||||
if args.platform and allowed and args.platform not in allowed:
|
||||
# The platform restriction applied only without --key: dolphin-sys
|
||||
# was refreshed for RomM, which never reads it.
|
||||
log.error(
|
||||
"%s does not serve %s (for_platforms: %s)",
|
||||
args.key, args.platform, ", ".join(allowed),
|
||||
)
|
||||
raise SystemExit(2)
|
||||
outcomes = {
|
||||
args.key: refresh_entry(
|
||||
args.key, registry[args.key], force=args.force, dry_run=args.dry_run
|
||||
|
||||
@@ -138,5 +138,22 @@ class TheVersionIsReadBeforeTheDownload(unittest.TestCase):
|
||||
self.assertEqual(json.loads(versions.read_text())["sys"]["sha"], "build-1")
|
||||
|
||||
|
||||
class AKeyMustServeThePlatform(unittest.TestCase):
|
||||
"""--platform narrowed only a full refresh: under --key it was ignored and
|
||||
dolphin-sys was refreshed for RomM, which never reads it."""
|
||||
|
||||
def test_a_key_outside_the_platform_is_refused(self):
|
||||
import subprocess # noqa: PLC0415
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
refused = subprocess.run(
|
||||
[sys.executable, "scripts/refresh_data_dirs.py", "--key", "dolphin-sys",
|
||||
"--platform", "romm", "--dry-run"],
|
||||
cwd=root, capture_output=True, text=True, timeout=120, check=False,
|
||||
)
|
||||
self.assertEqual(refused.returncode, 2)
|
||||
self.assertIn("does not serve romm", refused.stdout + refused.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user