fix: keep the md5 a mister entry already holds

A BiosDB entry is one record: md5, size and url describe one dump. The
first md5 the truth accepts replaced an accepted one with no change
reported. The exporter now writes record_hash, as RomM and System.dat do.
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 11:41:18 +01:00
1 parent 0418df5337
commit 4e5b48ddbe
2 files changed
+31 -4

No files matched your search

+21
View File
@@ -1849,6 +1849,27 @@ class MisterDatabaseComesBackAsWritten(unittest.TestCase):
self.assertEqual(len(exporter.withheld()), 1)
self.assertEqual(exporter.validate(systems, produced), [])
def test_an_accepted_hash_is_not_swapped_for_another(self):
"""The url serves MiSTer's dump, and the truth accepts it among two.
The first accepted md5 went in its place with no change reported,
and the Downloader refused every install of the file."""
database = {"db_id": "bios_db", "files": {
"games/X/boot.rom": {"hash": "b" * 32, "size": 10, "url": "u"},
}}
original = json.dumps(database)
scraped = {"systems": {"x": {"files": [{
"name": "boot.rom", "destination": "X/boot.rom", "md5": "b" * 32, "size": 10,
}]}}}
truth = {"systems": {"x": {"files": [{
"name": "boot.rom", "path": "X/boot.rom", "md5": ["a" * 32, "b" * 32],
"size": 10, "_cores": ["x"],
}]}}}
exporter = discover_exporters()["misterfpga"]()
systems, report = build_native_model(truth, scraped)
produced = exporter.render(systems, report, {"bios_db.json": original}, scraped)
self.assertEqual(produced["bios_db.json"], original)
self.assertEqual(exporter.validate(systems, produced), [])
def test_an_empty_truth_hands_back_the_database(self):
archive = UPSTREAM_CACHE / "misterfpga" / "bios_db.json.zip"
if not archive.exists():