fix: read on-card once with the folder facts

The plan rows, plan text and result screen asked on every frame whether the BIOS folder sits on its system's card, scanning the mounted drives each time. A card pulled out while the plan was open moved Check again from under the focus. The answer is now read with the other folder facts at the end of the check.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 00:29:38 +01:00
1 parent 06f87cf957
commit 0d0b6c54b7
7 files changed
+59 -29

No files matched your search

+7 -2
View File
@@ -29,6 +29,7 @@ from installer.destination import (
dest_drive,
missing_folder,
mounted_cards_of,
on_its_card,
)
from installer.detect_os import _DETECTED_OS, _FROM_CARD, detected_os, detected_shown
from installer.embedded import CARD_PLATFORMS, _a
@@ -763,9 +764,13 @@ def _tui_folder_facts(state: TuiState) -> dict:
free = None
cores = (installed_cores(core_dirs(state.platform, dest))
if state.platform in CORE_PLATFORMS else [])
# The retroarch.cfg that names dest, said under it on the plan.
# The retroarch.cfg that names dest, said under it on the plan. Whether
# dest is the card of its system is read here with the rest, never by
# a frame: a card pulled out moved the plan rows under the focus.
return {"free": free, "writable": _folder_writable(dest), "cores": cores,
"config": _retroarch_config_at(dest)}
"config": _retroarch_config_at(dest),
"on_card": on_its_card(state.platform, dest,
state.card_bound[0] if state.card_bound else "")}
def _row_folder(row: TuiRow) -> Path:
+4 -6
View File
@@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, NamedTuple
from installer.cards import card_bound
from installer.choices import available_choices, core_files, emulator_names
from installer.datadirs import select_data_directories
from installer.destination import dest_drive, on_its_card, shown_bios_folder
from installer.destination import dest_drive, shown_bios_folder
from installer.embedded import CARD_PLATFORMS
from installer.frontend_folders import save_directory_for, save_where_words
from installer.games import GAMES_REASONS
@@ -384,11 +384,9 @@ def _tui_card_bound(state: TuiState) -> tuple[str, str] | None:
def _on_its_card(state: TuiState) -> bool:
"""Whether the BIOS folder is on the SD card of the setup it is for, a
system that reads that card alone: room is made there, another folder
being one it never reads."""
if state.dest is None:
return False
return on_its_card(state.platform, state.dest,
state.card_bound[0] if state.card_bound else "")
being one it never reads. Read with the folder facts at the end of the
check, so every frame of the plan and the result shows the same rows."""
return state.dest is not None and bool(state.facts.get("on_card"))
def _dest_card(state: TuiState) -> Path | None: