From 804534397f9ed1759e59d8305a64b700ded83c6f Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 20 Oct 2026 18:54:28 +0200 Subject: [PATCH] fix: write the MiSTer database on one line The BiosDB is published as a single line of JSON without a final newline. Written with indent=2 it came out as 1499 changed lines for a database whose content had not changed, which would bury any real correction. It is now written in MiSTer's own form: an empty truth gives back the cached database byte for byte. --- scripts/exporter/misterfpga_exporter.py | 4 +++- tests/test_exporters.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/exporter/misterfpga_exporter.py b/scripts/exporter/misterfpga_exporter.py index 52e65a7b..ed5da927 100644 --- a/scripts/exporter/misterfpga_exporter.py +++ b/scripts/exporter/misterfpga_exporter.py @@ -105,7 +105,9 @@ class Exporter(BaseExporter): if size: entry["size"] = size - return {_DB_NAME: json.dumps(database, indent=2, ensure_ascii=False) + "\n"} + # MiSTer publishes the database as one line, without a final + # newline: written with an indent it came out as 1499 changed lines. + return {_DB_NAME: json.dumps(database, ensure_ascii=False)} def validate( self, diff --git a/tests/test_exporters.py b/tests/test_exporters.py index e6de511c..67351c8f 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -1420,6 +1420,22 @@ class BizhawkExport(unittest.TestCase): self.assertFalse(exporter.states(entry, "sha1")) +class MisterDatabaseComesBackAsWritten(unittest.TestCase): + """The BiosDB is one line of JSON. Written with indent=2 it came out as + 1499 changed lines for a database whose content had not changed.""" + + def test_an_empty_truth_hands_back_the_database(self): + archive = UPSTREAM_CACHE / "misterfpga" / "bios_db.json.zip" + if not archive.exists(): + self.skipTest("upstream cache not populated") + exporter = discover_exporters()["misterfpga"]() + originals = exporter.unpack(archive.read_bytes()) + config = native_layer(load_platform_config("misterfpga", str(REPO_ROOT / "platforms"))) + systems, report = build_native_model({"systems": {}}, config) + produced = exporter.render(systems, report, originals, config) + self.assertEqual(produced, originals) + + class RetrodeckManifestsComeBackAsWritten(unittest.TestCase): """With nothing to correct, a manifest is the platform's own bytes. The export added a final newline to nine of ten, wrote "md5": null where no