fix: one rule for the held file a hash names

The system index read sha1 and md5 only, the file lookup any index
with no size bound, the gap table any index unbounded. declared_records
in model.database follows the resolver: a crc32 names only a record of
the declared size, and beside a stronger hash only what it names.
systems.json gains 511 held files declared by sha256 or crc32, and 41
MAME members no longer point at Chihiro's ver1305.bin through the crc32
of an erased flash block.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:40 +01:00
1 parent f143a8719b
commit 40dadc5dcd
6 files changed
+98 -44

No files matched your search

+5 -7
View File
@@ -6,11 +6,11 @@ import urllib.parse
from collections.abc import Callable
from model.collection import group_by_manufacturer, manufacturer_slug
from model.database import sha1_at
from model.database import declared_records, sha1_at
from model.systemnames import system_name
from model.profiles import is_emulator
from sitegen.config import SITE_URL
from core.hashing import parse_hash_list
from core.hashing import declared_hash_lists
from sitegen.lookup import site_path
from sitegen.render import card_anchor
from sitegen.runlinks import console_href
@@ -30,7 +30,6 @@ def system_index_items(db: dict, coverages: dict, profiles: dict) -> list[dict]:
from sitegen.runlinks import card_page, system_section
files = db.get("files") or {}
by_md5 = (db.get("indexes") or {}).get("by_md5") or {}
held: dict[str, set[str]] = {}
for coverage in coverages.values():
for detail in coverage.get("details") or []:
@@ -48,10 +47,9 @@ def system_index_items(db: dict, coverages: dict, profiles: dict) -> list[dict]:
ids = ([str(entry["system"])] if entry.get("system")
else [str(s) for s in entry.get("systems") or []] or
(own if len(own) == 1 else []))
found = {v for v in parse_hash_list(entry.get("sha1")) if v in files}
for md5 in parse_hash_list(entry.get("md5")):
match = by_md5.get(md5)
found.update([match] if isinstance(match, str) else match or [])
found = {sha1 for named in declared_records(
db, declared_hash_lists(entry), entry.get("size")).values()
for sha1 in named}
for sys_id in ids:
held.setdefault(sys_id, set()).update(found)
manufacturers = {manufacturer_slug(mfr): mfr for mfr in group_by_manufacturer(db)}