mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 17:33:30 -05:00
fix: keep a MiSTer record whole without an md5
This commit is contained in:
1 parent
6458a927d4
commit
c254115647
2 files changed
+26
-3
No files matched your search
@@ -93,10 +93,14 @@ class Exporter(BaseExporter):
|
||||
fe = indexed.get(path)
|
||||
if fe is None:
|
||||
continue
|
||||
self._written.add(id(fe))
|
||||
md5 = fe.hash("md5")
|
||||
if md5:
|
||||
entry["hash"] = md5
|
||||
if not md5:
|
||||
# The record is checked by its md5: where the truth takes the
|
||||
# entry without one, a new size beside the old hash describes
|
||||
# no file, and the entry is left as MiSTer wrote it.
|
||||
continue
|
||||
self._written.add(id(fe))
|
||||
entry["hash"] = md5
|
||||
size = fe.size()
|
||||
if size:
|
||||
entry["size"] = size
|
||||
|
||||
@@ -325,6 +325,25 @@ class MisterCountsWhatItWrites(unittest.TestCase):
|
||||
self.assertTrue(exporter.states(held, "md5"))
|
||||
self.assertFalse(exporter.states(absent, "md5"))
|
||||
|
||||
def test_a_truth_without_md5_leaves_the_record_whole(self):
|
||||
# The truth took the entry on a size contradiction and has no md5:
|
||||
# the render kept MiSTer's hash, wrote the new size, and the summary
|
||||
# announced the hash cleared.
|
||||
from export_native import landed_changes # noqa: PLC0415
|
||||
|
||||
fe = NativeFile("boot.rom", "NES/boot.rom", "nes",
|
||||
platform={"md5": A, "size": 100},
|
||||
truth={"sha1": "f" * 40, "size": 200})
|
||||
systems = {"nes": NativeSystem("nes", files=[fe])}
|
||||
database = {"db_id": "x", "files": {
|
||||
"games/NES/boot.rom": {"hash": A, "size": 100, "url": "u"}}}
|
||||
exporter = Mister()
|
||||
produced = exporter.render(systems, None, {"bios_db.json": json.dumps(database)})
|
||||
written = json.loads(produced["bios_db.json"])["files"]["games/NES/boot.rom"]
|
||||
self.assertEqual((written["hash"], written["size"]), (A, 100))
|
||||
changes = landed_changes(exporter, systems)
|
||||
self.assertEqual((changes.cleared, changes.resized), ([], []))
|
||||
|
||||
|
||||
class OneMd5FormatsAddWhole(unittest.TestCase):
|
||||
def test_an_addition_with_several_md5_is_refused(self):
|
||||
|
||||
Reference in new issue
Block a user