fix: write retrodeck repeats to each component

duckstation and retroarch both list the PS1 BIOS with one md5, and the
entry was filed under the first component read: an export correction
reached duckstation's manifest and left retroarch's line as it was.
component now lists every component that repeats an entry (a string for
one), and the exporter writes the entry back to each. A repeat is the
same name, path, hashes, native system and requirement: MAME's and
FBNeo's cchip.zip, or two required labels, stay two entries, since an
export corrects a line by its system and writes its requirement back.
Rescraped at components fcd0d729: 73 entries list two components, 9
come back as their own entries. install/retrodeck.json is unchanged.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 21:04:19 +01:00
1 parent e8704a793e
commit 3779f07bb5
8 files changed
+433 -104

No files matched your search

+2 -1
View File
@@ -19,6 +19,7 @@ from resolve.archives import contents_members, holds_required_members
from resolve.standalone import platform_layouts, standalone_set
from resolve.cores import resolve_platform_cores
from core.hashing import declared_hash_lists, lists_hashes
from model.declarations import declared_components
from model.profiles import lists_files
from resolve.collisions import accepted_by_all, find_collisions
from resolve.content import size_fits
@@ -110,7 +111,7 @@ def doubled_destinations(
readers.append(reader)
declarations.append({
"system": entry.get("native_system") or "",
"component": entry.get("component") or "",
"component": ", ".join(declared_components(entry.get("component"))),
"name": entry.get("name", ""),
"hashes": declared_hash_lists(entry),
"file": local,
+18 -12
View File
@@ -14,6 +14,7 @@ from collections import OrderedDict
from .base_exporter import BaseExporter
from core.hashing import parse_hash_list
from model.declarations import declared_components
from resolve.reconcile import NativeFile, NativeSystem, Report
COMPONENTS_REPO = "RetroDECK/components"
@@ -78,6 +79,12 @@ def _pick(
return free[0] if free else None
def _components(fe: NativeFile) -> list[str]:
"""The manifests an entry is written back to: every component that
declares it, an addition's own once placed."""
return declared_components(fe.native("component", ""))
class Exporter(BaseExporter[str]):
"""Write RetroDECK's component manifests, corrected."""
@@ -101,7 +108,7 @@ class Exporter(BaseExporter[str]):
def writable(self, fe: NativeFile, require: str = "") -> bool:
"""An addition lands only in a manifest it can be placed in."""
if fe.platform is None and not fe.native("component", ""):
if fe.platform is None and not _components(fe):
return False
return super().writable(fe, require)
@@ -141,9 +148,10 @@ class Exporter(BaseExporter[str]):
"""
for system in systems.values():
components = {
str(fe.native("component", ""))
component
for fe in system.files
if fe.platform is not None and fe.native("component", "")
if fe.platform is not None
for component in _components(fe)
}
if len(components) != 1:
continue
@@ -161,13 +169,10 @@ class Exporter(BaseExporter[str]):
def components(self, systems: dict[str, NativeSystem]) -> list[str]:
"""Components the corrected data touches."""
found: set[str] = set()
for system in systems.values():
for fe in system.files:
component = str(fe.native("component", ""))
if component:
found.add(component)
return sorted(found)
return sorted(
{component for system in systems.values() for fe in system.files
for component in _components(fe)}
)
@staticmethod
def _entry(fe: NativeFile) -> OrderedDict:
@@ -204,11 +209,12 @@ class Exporter(BaseExporter[str]):
def _by_component(
self, systems: dict[str, NativeSystem]
) -> dict[str, list[NativeFile]]:
"""Each component's entries. An entry several manifests repeat with
the same hashes and requirement is written back to each of them."""
grouped: dict[str, list[NativeFile]] = {}
for system in systems.values():
for fe in system.files:
component = str(fe.native("component", ""))
if component:
for component in _components(fe):
grouped.setdefault(component, []).append(fe)
return grouped