fix: read variant zip copies as archives

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:02:28 +01:00
1 parent 51f6898cee
commit b9441c545d
8 files changed
+52 -12

No files matched your search

+13
View File
@@ -576,6 +576,19 @@ class ArchiveMembersAreHeld(unittest.TestCase):
self.assertEqual(report["no-intro"]["matched"], 1)
self.assertEqual([e["name"] for e in report["no-intro"]["missing"]], ["other.bin"])
def test_member_of_a_variant_copy_counts_as_held(self):
"""A .variants/x.zip.<md5> copy was skipped: dumps only it holds
stayed acquisition targets."""
from scripts.acquire.provenance import archive_members
with tempfile.TemporaryDirectory() as tmp:
copy = Path(tmp) / "bbcm.zip.4cc3e25a"
with zipfile.ZipFile(copy, "w") as zf:
zf.writestr("mos.rom", b"mos")
members = archive_members({"files": {"z": {"path": str(copy)}}})
self.assertEqual([m for ms in members.values() for _p, m in ms], ["mos.rom"])
class OneDumpIsCountedOnce(unittest.TestCase):
"""No-Intro's three FM-7 DATs each list DICROM.rom and KANJI.rom: the
report said 2 485 missing where 2 284 distinct dumps were missing, and
+19
View File
@@ -149,6 +149,25 @@ class PoolAndBuild(unittest.TestCase):
self.assertIsNone(reconstruct("0" * 32, {"v1": [("a.rom", "ffffffff")]}, self.pool))
class AVariantCopyIsAnArchive(unittest.TestCase):
"""AtomPool listed bios/**/*.zip: bbcm.zip.4cc3e25a's members were never
atoms, so --missing called a recipe unbuildable that --build rebuilt,
and the copy itself was indexed as a loose ROM."""
def test_its_members_are_atoms_and_the_copy_is_no_rom(self):
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
bios = Path(directory)
copy = bios / "Acorn" / ".variants" / "bbcm.zip.4cc3e25a"
copy.parent.mkdir(parents=True)
with zipfile.ZipFile(copy, "w") as archive:
archive.writestr("a.rom", ROM_A)
container = f"{zlib.crc32(copy.read_bytes()):08x}"
db = {"files": {"s": {"path": str(copy), "crc32": container}}}
pool = AtomPool(bios, db=db)
self.assertEqual(pool.read(_crc(ROM_A)), ROM_A)
self.assertNotIn(container, pool)
class ReportsOverAFixture(unittest.TestCase):
"""A whole run over a synthetic collection, database and platform."""