fix: pair truth entries hash-consistent first

Each truth entry claimed its platform line in turn, so the first one to
arrive won. dosbox-x's system.rom (alias bios.rom, no path) took
Batocera's np2kai/BIOS.ROM by name before np2kai's own np2kai/bios.rom
was tried, and the export wrote an IBM PCjr md5 on it. A path also
outranked a contradicting hash: the truth's MSX.rom joins bluemsx's path
and fmsx's md5, which replaced the blueMSX dump on Recalbox's and
System.dat's Machines/Shared Roms/MSX.rom while fmsx's own line held it.

pair_entries runs each test over every entry before the next, tests that
contradict no hash first. export_native and diff_truth both read it.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 14:24:00 +02:00
1 parent 19974e34b8
commit 181ad0c630
4 files changed
+155 -45

No files matched your search

+9 -10
View File
@@ -618,13 +618,12 @@ def _hash_mismatch(t_entry: dict, s_entry: dict) -> dict | None:
def _diff_system(truth_sys: dict, scraped_sys: dict) -> dict:
"""Compare files between truth and scraped for a single system.
Entries are paired by pair_truth_entry, the rule export_native applies:
destination, then name or alias in the same directory at the same size,
then any hash in common. Two rules had diverged, and diff_truth flagged
a hash the export did not correct while the export corrected hashes the
diff never named. An entry never answers for two.
Entries are paired by pair_entries, the rule export_native applies. Two
rules had diverged, and diff_truth flagged a hash the export did not
correct while the export corrected hashes the diff never named. An entry
never answers for two.
"""
from exporter.baseline import _is_placeholder, pair_truth_entry, platform_declares
from exporter.baseline import _is_placeholder, pair_entries, platform_declares
truth_files = [
fe for fe in truth_sys.get("files", [])
@@ -639,9 +638,10 @@ def _diff_system(truth_sys: dict, scraped_sys: dict) -> dict:
extra_phantom: list[dict] = []
extra_unprofiled: list[dict] = []
claimed: set[int] = set()
for t_entry in truth_files:
s_position = pair_truth_entry(t_entry, scraped_files, claimed)
pairs = pair_entries(truth_files, scraped_files)
claimed = set(pairs.values())
for t_index, t_entry in enumerate(truth_files):
s_position = pairs.get(t_index)
if s_position is None:
if not platform_declares(t_entry, scraped_files):
missing.append(
@@ -652,7 +652,6 @@ def _diff_system(truth_sys: dict, scraped_sys: dict) -> dict:
}
)
continue
claimed.add(s_position)
s_entry = scraped_files[s_position]
mismatch = _hash_mismatch(t_entry, s_entry)
if mismatch: