mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-03 06:48:52 -06:00
fix: one rule for the held file a hash names
The system index read sha1 and md5 only, the file lookup any index with no size bound, the gap table any index unbounded. declared_records in model.database follows the resolver: a crc32 names only a record of the declared size, and beside a stronger hash only what it names. systems.json gains 511 held files declared by sha256 or crc32, and 41 MAME members no longer point at Chihiro's ver1305.bin through the crc32 of an erased flash block.
This commit is contained in:
1 parent
f143a8719b
commit
40dadc5dcd
6 files changed
+98
-44
No files matched your search
@@ -15,7 +15,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from model.database import record_for_hash, records_for_hash
|
||||
from model.database import declared_records, record_for_hash, records_for_hash
|
||||
from packs.crossref import entry_source
|
||||
from packs.integrity import _repo_satisfies_declaration
|
||||
from resolve.localfile import held_record_for
|
||||
@@ -55,6 +55,38 @@ class RecordsForHash(unittest.TestCase):
|
||||
self.assertEqual(records_for_hash(db, "md5", MD5_B[:29]), [])
|
||||
|
||||
|
||||
class DeclaredRecords(unittest.TestCase):
|
||||
"""The site's system index, file lookup and gap table name a held file
|
||||
by one rule: systems.json missed 494 files declared by crc32 or sha256."""
|
||||
|
||||
def setUp(self):
|
||||
self.db = _db(
|
||||
{SHA_A: {"path": "a", "size": 4}, SHA_B: {"path": "b", "size": 8}},
|
||||
by_md5={MD5_A: SHA_A}, by_sha256={"f" * 64: SHA_B},
|
||||
by_crc32={"deadbeef": SHA_A, "cafef00d": SHA_B},
|
||||
)
|
||||
|
||||
def test_a_crc32_alone_names_a_record_of_the_declared_size(self):
|
||||
found = declared_records(self.db, {"crc32": ["deadbeef"]}, 4)
|
||||
self.assertEqual(found, {("crc32", "deadbeef"): [SHA_A]})
|
||||
found = declared_records(self.db, {"crc32": ["deadbeef"]}, [8, 16])
|
||||
self.assertEqual(found, {("crc32", "deadbeef"): []})
|
||||
|
||||
def test_a_crc32_beside_a_stronger_hash_names_what_that_hash_names(self):
|
||||
# An erased flash block shares its crc32 with every other one.
|
||||
found = declared_records(self.db, {"sha1": [SHA_B], "crc32": ["deadbeef"]})
|
||||
self.assertEqual(found, {("sha1", SHA_B): [SHA_B], ("crc32", "deadbeef"): []})
|
||||
found = declared_records(self.db, {"md5": [MD5_A], "crc32": ["deadbeef"]})
|
||||
self.assertEqual(found[("crc32", "deadbeef")], [SHA_A])
|
||||
|
||||
def test_sha256_and_a_cut_md5_name_their_record(self):
|
||||
found = declared_records(self.db, {"sha256": ["f" * 64], "md5": [MD5_A[:29]]})
|
||||
self.assertEqual(found, {("sha256", "f" * 64): [SHA_B], ("md5", MD5_A[:29]): [SHA_A]})
|
||||
|
||||
def test_an_algorithm_without_an_index_names_nothing(self):
|
||||
self.assertEqual(declared_records(self.db, {"adler32": ["1234abcd"]}), {})
|
||||
|
||||
|
||||
class GapReportHeldRule(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.db = _db(
|
||||
|
||||
Reference in new issue
Block a user