mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Backend: - One session-scan iterator (`_iter_session_keys` / `_iter_live_sessions`) replaces three copies of the Redis scan-and-decode loop, and `_get_live_session` replaces five independent "a drain marker is nobody's session" checks. - `_abort_claim` replaces seven inlined claim-abort cleanups, so a new failure branch can no longer wedge a container and orphan a blank card. - `_quiesce_container` and `_collect_exit_state` replace the stop-evacuate-wipe and guarded state-pull blocks written out in all three teardown paths. The `_record_termination` calls stay at the call sites: the three order it differently and each has its own reason. - `_hold_reservation` / `_drop_reservation` collapse the two release-after-state-pull helpers into one, and absorb the third copy of that branch inlined in the released-session teardown. - `_load_state_broker`'s two protocol branches were byte-identical, so it now takes its route from `_transfer_route`; `_raise_broker_http_error` and `_raise_broker_unreachable` replace the error translation copied into `_call_broker` and `_webstation_activate`. - `_container_labels` builds the label map once per request rather than re-reading and re-parsing config.yml for every listed row. - The joinable listing fetches each ROM once, through `get_rom_simple` rather than the `@with_details` query, for five columns. - `store_memory_card_version` hands the hash it computed in memory to the scan, which was reading the archive back off disk to recompute it. - `_prune_state_history` takes the history its caller already fetched. - `playlist_files` in utils/m3u.py is now the one home for "which files are discs", shared by the download endpoint, the m3u generator and the swapper. Frontend: - `useActivityPresence` replaces the presence block copied verbatim from EmulatorJS.vue into Stream.vue. - `MemoryCardNameDialog` replaces three copies of the same name-entry dialog. - The two private axios error extractors give way to the `errorMessage` util, three hand-rolled spinners to `RSpinner`, six manual listener pairs to `useEventListener`, and five copy-on-write Set/Map trackers to `reactive`. - `keepaliveHeaders` moves next to the interceptor that owns the CSRF header. - The exit chord polls at 10Hz instead of every frame, the stage measures its offset once instead of per mousemove, `postToStream` reuses the frame list the attach pass walked, and the admin/home polls skip a hidden tab. - `containerLabelForPlatform` on the store replaces the two `streamLabel` definitions that answered differently, and the stream/join action labels move onto useGameActions so the button and the menu cannot word them differently. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
30 lines
986 B
Python
30 lines
986 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from models.rom import RomFile
|
|
|
|
|
|
def playlist_files(files: list[RomFile]) -> list[RomFile]:
|
|
"""The files of a multi-file ROM that name a playable disc.
|
|
|
|
The .m3u itself is never one, and where .cue files are present only those
|
|
are, since the raw .bin tracks they reference are not loadable on their own.
|
|
One home for the rule: the playlist, the download endpoint and the disc
|
|
swapper all have to agree on which files are discs.
|
|
"""
|
|
discs = [f for f in files if f.file_extension.lower() != "m3u"]
|
|
cue_files = [f for f in discs if f.file_extension.lower() == "cue"]
|
|
return cue_files or discs
|
|
|
|
|
|
def generate_m3u_content(
|
|
files: list[RomFile],
|
|
hidden_folder: bool,
|
|
) -> bytes:
|
|
"""Generate M3U playlist content for multi-file ROMs."""
|
|
return "\n".join(
|
|
f.file_name_for_download(hidden_folder) for f in playlist_files(files)
|
|
).encode()
|