diff --git a/scripts/exporter/baseline.py b/scripts/exporter/baseline.py index aa10ed78e..af09d300f 100644 --- a/scripts/exporter/baseline.py +++ b/scripts/exporter/baseline.py @@ -148,8 +148,10 @@ class NativeFile: # platform gives it), empty when no core the platform runs is named. runners: list[tuple[bool, str]] = field(default_factory=list) # The platform reads this file's md5 as a composite of its members - # (Recalbox on a .zip): the truth's md5 describes the container and - # can be neither compared with it nor written in its place. + # (Recalbox on a .zip) or as one member's (Batocera's zippedFile, which + # checkInsideZip compares inside the archive): the truth's md5 describes + # the container and can be neither compared with it nor written in its + # place. composite_md5: bool = False # Every truth entry of the system that answers to this platform entry's # name, whichever one the pairing took: the element names its cores, and @@ -531,7 +533,8 @@ def build_native_model( destination=destination, native_system=native_id, platform=file_entry, - composite_md5=file_entry.get("zip_digest") == "composite", + composite_md5=file_entry.get("zip_digest") == "composite" + or bool(file_entry.get("zipped_file")), ) ) report.files_kept += 1 diff --git a/tests/test_exporters.py b/tests/test_exporters.py index af6ad3f26..6a21dd740 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -499,6 +499,23 @@ class Reconciliation(unittest.TestCase): systems, _ = build_native_model({"systems": {}}, scraped) self.assertEqual(sorted(systems), ["pcengine", "supergrafx"]) + def test_a_container_md5_leaves_a_zipped_file_md5_alone(self): + """Batocera's checkInsideZip compares a zippedFile item's md5 with + the member's. A profile's container md5 was written in its place + and counted as a hash updated to the emulator source.""" + scraped = {"systems": {"pc6001": {"native_id": "pc6001", "files": [ + {"name": "pc6001.zip", "destination": "pc6001.zip", "md5": "1" * 32, + "zipped_file": "basicrom.60"}, + ]}}} + truth = {"systems": {"pc6001": {"files": [ + {"name": "pc6001.zip", "md5": "2" * 32}, + ]}}} + systems, report = build_native_model(truth, scraped) + entry = systems["pc6001"].files[0] + self.assertEqual(entry.corrections, []) + self.assertEqual(report.hashes_corrected, []) + self.assertEqual(entry.hashes("md5"), ["1" * 32]) + def test_an_addition_joins_the_native_id_its_cores_read(self): """RetroDECK's arcade spans mame and fbneo with no primary id. Every addition went under fbneo, the first sorted, MAME device archives