fix: write no platform size beside a truth hash

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 11:53:18 +02:00
1 parent 5f62597e6f
commit db179faf82
2 files changed
+22 -1

No files matched your search

+7 -1
View File
@@ -153,9 +153,15 @@ class NativeFile:
truth's size is only taken when the truth also speaks for the hash:
a name-matched 480-byte fbneo boot.bin turned RomM's Dreamcast
boot.bin into size 480 beside its 2 MB md5, which never verifies.
When the truth contradicts the platform's hash, the platform's size
describes the dump the truth rejects: geolith's neocdz.zip md5 went
out beside System.dat's 953078 bytes, a record no file satisfies.
"""
source = self._identity_source()
order = (self.platform, self.truth) if source == "platform" else (self.truth, self.platform)
order = {
"platform": (self.platform, self.truth),
"truth": (self.truth,),
}.get(source, (self.truth, self.platform))
for entry in order:
if entry and entry.get("size"):
return _single_size(entry["size"])
+15
View File
@@ -136,6 +136,21 @@ class Reconciliation(unittest.TestCase):
self.assertIsNone(platform_entry.truth)
self.assertEqual(report.hashes_corrected, [])
def test_a_contradicted_hash_takes_no_platform_size(self):
"""geolith's neocdz.zip md5 contradicts System.dat's: the export
wrote that md5 beside System.dat's 953078 bytes."""
entry = NativeFile(
"neocdz.zip", "neocdz.zip", "neocd",
platform={"md5": "a" * 32, "size": 953078},
truth={"md5": "b" * 32},
)
self.assertEqual((entry.hash("md5"), entry.size()), ("b" * 32, None))
agreeing = NativeFile(
"neocdz.zip", "neocdz.zip", "neocd",
platform={"md5": "b" * 32, "size": 955352}, truth={"md5": "b" * 32},
)
self.assertEqual(agreeing.size(), 955352)
def test_a_file_the_truth_says_nothing_about_is_kept(self):
systems, _ = model()
names = {fe.name for fe in systems["psx"].files}