mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
fix: match a loose dump by crc32 and size
This commit is contained in:
1 parent
9cb152ef23
commit
3baec1794b
2 files changed
+22
No files matched your search
@@ -88,6 +88,13 @@ def build_report(db: dict, snapshots: dict, members: dict | None = None) -> dict
|
||||
by_md5_size = {
|
||||
(entry.get("md5", ""), entry.get("size", 0)) for entry in by_sha1.values()
|
||||
}
|
||||
# Redump lists some dumps by crc32 alone (ps2-0101jd-20030110, DTL-H10100):
|
||||
# collected as a loose file it would stay MISSING for good without this.
|
||||
by_crc32_size = {
|
||||
(str(entry.get("crc32", "")).lower(), entry.get("size", 0))
|
||||
for entry in by_sha1.values()
|
||||
if entry.get("crc32")
|
||||
}
|
||||
|
||||
report = {}
|
||||
for source, snapshot in sorted(snapshots.items()):
|
||||
@@ -98,6 +105,7 @@ def build_report(db: dict, snapshots: dict, members: dict | None = None) -> dict
|
||||
if (
|
||||
entry.get("sha1") in by_sha1
|
||||
or (entry.get("md5"), entry.get("size")) in by_md5_size
|
||||
or (str(entry.get("crc32") or "").lower(), entry.get("size")) in by_crc32_size
|
||||
or _held_in_archive(entry, members)
|
||||
):
|
||||
matched += 1
|
||||
|
||||
@@ -353,6 +353,20 @@ class TestProvenanceReport(unittest.TestCase):
|
||||
report["redump"]["covered_dats"], ["Sony - PlayStation - BIOS Images"]
|
||||
)
|
||||
|
||||
def test_a_loose_file_matches_by_crc32_and_size(self):
|
||||
"""Redump lists DTL-H10100's image by crc32 alone; collected as a
|
||||
loose file it stayed MISSING for good."""
|
||||
db = {"files": {"f" * 40: {"name": "ps2-0101jd.bin", "size": 4194304,
|
||||
"md5": "e" * 32, "crc32": "E9836A0C"}}}
|
||||
snapshots = {"redump": {"source": "redump", "imported_at": "2026-10-09",
|
||||
"dats": {"PS2 BIOS": "2026-10-01"},
|
||||
"entries": [{"name": "ps2-0101jd.bin", "size": 4194304,
|
||||
"crc32": "e9836a0c", "md5": "", "sha1": "",
|
||||
"dat": "PS2 BIOS"}]}}
|
||||
report = build_report(db, snapshots)
|
||||
self.assertEqual(report["redump"]["matched"], 1)
|
||||
self.assertEqual(report["redump"]["missing"], [])
|
||||
|
||||
def test_uncovered_dat_entries_are_out_of_scope(self):
|
||||
"""Entries from a DAT the collection never matches are not targets.
|
||||
|
||||
|
||||
Reference in new issue
Block a user