fix: one rule for a recorded file's systems

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 01:14:04 +01:00
1 parent 61c143e984
commit 374891b83e
7 files changed
+69 -29

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
# the site's build rewrites this line there (scripts/sitebootstrap.py).
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
$defaultInstallSha256 = "aacb100cb625bc36fd7c9fa61de44949d23490c7ca09c2501e2321c6f72077a1"
$defaultInstallSha256 = "d192a33af92cb83bdbf1d436fd4458dec4fac18f4a5cff1ea25ee8de0413630d"
# The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed.
$maximumInstallerBytes = 8MB
+21 -9
View File
@@ -20177,6 +20177,24 @@ def _served(manifest: dict, fold: bool) -> dict[tuple[str, str], tuple]:
return served
def _recorded_served(setup: dict, manifest: dict, fold: bool
) -> list[tuple[dict, tuple[str, str], tuple]]:
"""Each file a setup's record holds, with its place as the drive opens
it and what the list serves there, by the one rule removal reads."""
served = _served(manifest, fold)
places = [(item, (str(item.get("root") or ""), _drive_key(str(item["dest"]), fold)))
for item in setup.get("files") or []]
return [(item, place, served.get(place, (set(), [], set(), False)))
for item, place in places]
def recorded_systems(setup: dict, manifest: dict, folder: Path) -> list[tuple[dict, list[str]]]:
"""Each file a setup's record holds, with the list's systems of it: a
drive that folds case finds a recased dest under the list's spelling."""
return [(item, list(found[1]))
for item, _place, found in _recorded_served(setup, manifest, not keeps_case(folder))]
def _choice_names(options: list[tuple[str, str | None]], flag: str) -> list[str]:
return [name.strip() for option, value in options if option == flag
for name in (value or "").split(",") if name.strip()]
@@ -20342,15 +20360,12 @@ def plan_removal(
folder = Path(os.path.abspath(folder))
setup = record["setups"][plat]
fold = not keeps_case(folder)
served = _served(manifest, fold)
scope = _removal_scope(plat, record, manifest, fold, systems=systems, cores=cores,
emulators=emulators, files=files)
planned_entries: dict[str, list] = {"remove": [], "kept": [], "gone": []}
picked: set[str] = set()
planned: set[tuple[str, str]] = set()
for item in setup.get("files") or []:
key = (str(item.get("root") or ""), scope.norm(str(item["dest"])))
found = served.get(key, (set(), [], set(), False))
for item, key, found in _recorded_served(setup, manifest, fold):
if not _removal_takes(scope, found, str(item["dest"])):
continue
if key in planned:
@@ -25286,13 +25301,10 @@ def _ticked_estimate(state: TuiState) -> tuple[int, int]:
def tui_removal_systems(state: TuiState) -> list[tuple[str, int, int]]:
"""(system, files, bytes) of each system the install record holds files
of, by the list's systems, in the order Choose systems lists them."""
if state.record is None or state.manifest is None:
if state.record is None or state.manifest is None or state.dest is None:
return []
served = _served(state.manifest, False)
held: dict[str, list[int]] = {}
for item in state.record.get("files") or []:
systems = served.get((str(item.get("root") or ""), str(item["dest"])),
(set(), [], set(), False))[1]
for item, systems in recorded_systems(state.record, state.manifest, state.dest):
for system in systems or [OTHER_SYSTEMS]:
tally = held.setdefault(system, [0, 0])
tally[0] += 1
+1 -1
View File
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
# curl or wget stop on a cut transfer before the hash is read: the site's
# build rewrites this line there (scripts/sitebootstrap.py).
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
DEFAULT_INSTALL_SHA256="aacb100cb625bc36fd7c9fa61de44949d23490c7ca09c2501e2321c6f72077a1"
DEFAULT_INSTALL_SHA256="d192a33af92cb83bdbf1d436fd4458dec4fac18f4a5cff1ea25ee8de0413630d"
# The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed.
MAX_INSTALLER_BYTES=8388608
+8 -8
View File
@@ -27,8 +27,8 @@
{
"dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py",
"size": 1488785,
"sha256": "aacb100cb625bc36fd7c9fa61de44949d23490c7ca09c2501e2321c6f72077a1",
"size": 1489469,
"sha256": "d192a33af92cb83bdbf1d436fd4458dec4fac18f4a5cff1ea25ee8de0413630d",
"executable": false
},
{
@@ -71,8 +71,8 @@
"muos": {
"archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1542410,
"sha256": "91808aad8fa4b58666d46b6e519ac6d272d124f23ffcf2cf72712d02aa813ba8"
"size": 1543094,
"sha256": "aa846698dc8dcfcc8dcf175ef0664c72de09ab34cece612cbb5c5de3e56c1310"
},
"members": [
{
@@ -92,8 +92,8 @@
{
"name": "RetroBIOS/install.py",
"repo_path": "install.py",
"size": 1488785,
"sha256": "aacb100cb625bc36fd7c9fa61de44949d23490c7ca09c2501e2321c6f72077a1",
"size": 1489469,
"sha256": "d192a33af92cb83bdbf1d436fd4458dec4fac18f4a5cff1ea25ee8de0413630d",
"executable": false
},
{
@@ -166,8 +166,8 @@
{
"dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py",
"size": 1488785,
"sha256": "aacb100cb625bc36fd7c9fa61de44949d23490c7ca09c2501e2321c6f72077a1",
"size": 1489469,
"sha256": "d192a33af92cb83bdbf1d436fd4458dec4fac18f4a5cff1ea25ee8de0413630d",
"executable": false
},
{
+19 -4
View File
@@ -131,6 +131,24 @@ def _served(manifest: dict, fold: bool) -> dict[tuple[str, str], tuple]:
return served
def _recorded_served(setup: dict, manifest: dict, fold: bool
) -> list[tuple[dict, tuple[str, str], tuple]]:
"""Each file a setup's record holds, with its place as the drive opens
it and what the list serves there, by the one rule removal reads."""
served = _served(manifest, fold)
places = [(item, (str(item.get("root") or ""), _drive_key(str(item["dest"]), fold)))
for item in setup.get("files") or []]
return [(item, place, served.get(place, (set(), [], set(), False)))
for item, place in places]
def recorded_systems(setup: dict, manifest: dict, folder: Path) -> list[tuple[dict, list[str]]]:
"""Each file a setup's record holds, with the list's systems of it: a
drive that folds case finds a recased dest under the list's spelling."""
return [(item, list(found[1]))
for item, _place, found in _recorded_served(setup, manifest, not keeps_case(folder))]
def _choice_names(options: list[tuple[str, str | None]], flag: str) -> list[str]:
return [name.strip() for option, value in options if option == flag
for name in (value or "").split(",") if name.strip()]
@@ -296,15 +314,12 @@ def plan_removal(
folder = Path(os.path.abspath(folder))
setup = record["setups"][plat]
fold = not keeps_case(folder)
served = _served(manifest, fold)
scope = _removal_scope(plat, record, manifest, fold, systems=systems, cores=cores,
emulators=emulators, files=files)
planned_entries: dict[str, list] = {"remove": [], "kept": [], "gone": []}
picked: set[str] = set()
planned: set[tuple[str, str]] = set()
for item in setup.get("files") or []:
key = (str(item.get("root") or ""), scope.norm(str(item["dest"])))
found = served.get(key, (set(), [], set(), False))
for item, key, found in _recorded_served(setup, manifest, fold):
if not _removal_takes(scope, found, str(item["dest"])):
continue
if key in planned:
+3 -6
View File
@@ -19,7 +19,7 @@ from installer.paths import SavePlace, spelled
from installer.plan_words import NO_CORE_FILES, _core_sized, emptied_words
from installer.platforms import _tui_system_label, system_title
from installer.regions import region_title
from installer.removal import _served
from installer.removal import recorded_systems
from installer.tally import tally
from installer.text import _names_and, _plural, agree
from installer.tui_commands import _core_base, _tui_system_flags, _tui_systems_chosen, tui_flags, tui_run_files
@@ -541,13 +541,10 @@ def _ticked_estimate(state: TuiState) -> tuple[int, int]:
def tui_removal_systems(state: TuiState) -> list[tuple[str, int, int]]:
"""(system, files, bytes) of each system the install record holds files
of, by the list's systems, in the order Choose systems lists them."""
if state.record is None or state.manifest is None:
if state.record is None or state.manifest is None or state.dest is None:
return []
served = _served(state.manifest, False)
held: dict[str, list[int]] = {}
for item in state.record.get("files") or []:
systems = served.get((str(item.get("root") or ""), str(item["dest"])),
(set(), [], set(), False))[1]
for item, systems in recorded_systems(state.record, state.manifest, state.dest):
for system in systems or [OTHER_SYSTEMS]:
tally = held.setdefault(system, [0, 0])
tally[0] += 1
+16
View File
@@ -501,6 +501,22 @@ class AFoldingDrive(unittest.TestCase):
self.assertEqual([(item["reason"], item["what"]) for item in removal.kept],
[("shared", "Lakka")])
def test_remove_by_system_counts_a_recased_file_as_the_plan_takes_it(self):
record = _record(self.folder, [_item("SCPH5501.BIN", self.payload)])
state = install.TuiState()
state.dest = self.folder
state.record = record["setups"]["retroarch"]
state.manifest = _served(("scph5501.bin", self.payload))
with mock.patch.object(install, "keeps_case", return_value=False):
shown = install.tui_removal_systems(state)
removal = install.plan_removal("retroarch", self.folder, record, state.manifest,
systems=["nintendo-gba"])
self.assertEqual(shown, [("nintendo-gba", 1, len(self.payload))])
self.assertEqual([entry["dest"] for entry in removal.remove], ["SCPH5501.BIN"])
with mock.patch.object(install, "keeps_case", return_value=True):
self.assertEqual([system for system, _count, _size
in install.tui_removal_systems(state)], [install.OTHER_SYSTEMS])
def test_the_removal_runs_on_a_folding_drive(self):
removal = self.plan(False)
record = _record(self.folder, [_item("SCPH5501.BIN", self.payload)])