fix(streaming): address Greptile review of the RetroArch state core

A broker too old to name its core also doesn't refuse a pushed state from
another core, so hydration with no core filter now only sends a newest
state that has no recorded core, and otherwise sends nothing.
This commit is contained in:
Zach Clendenen
2026-09-27 17:55:25 -05:00
parent 910469c402
commit da6edad29a
2 changed files with 19 additions and 2 deletions
+4
View File
@@ -599,6 +599,10 @@ async def hydrate_states_to_broker(
return 0
newest = states[0]
# A broker that can't name its core doesn't refuse another core's state.
if state_core is None and newest.core is not None:
log.info("not hydrating a %s state into an unnamed core", newest.core)
return 0
try:
content = await fs_asset_handler.read_file(
f"{newest.file_path}/{newest.file_name}"
+15 -2
View File
@@ -4943,14 +4943,27 @@ def test_hydrate_pushes_nothing_when_no_state_matches(rom: Rom, admin_user: User
push.assert_not_called()
def test_hydrate_filters_nothing_when_the_core_is_unknown(rom: Rom, admin_user: User):
def test_hydrate_pushes_an_unrecorded_state_when_the_core_is_unknown(
rom: Rom, admin_user: User
):
"""No configured core and a broker that can't name its default is how every
RetroArch launch ran before cores were recorded."""
_core_state(rom, admin_user, "Game.state", "whatever")
_core_state(rom, admin_user, "Game.state", None)
push = _hydrate_core(rom, admin_user, "retroarch", None)
assert push.call_args.args[1:] == ("Game.state", b"state-bytes", None)
def test_hydrate_pushes_nothing_recorded_when_the_core_is_unknown(
rom: Rom, admin_user: User
):
"""A broker too old to name its core doesn't refuse another core's state
either, so a newest state with a recorded core stays home."""
_core_state(rom, admin_user, "Old.state", None)
_core_state(rom, admin_user, "New.state", "bsnes")
push = _hydrate_core(rom, admin_user, "retroarch", None)
push.assert_not_called()
def test_hydrate_pushes_nothing_into_a_configured_core_it_cannot_match(
rom: Rom, admin_user: User
):