mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 05:18:51 -06:00
refactor: read archive members in one place
core.ziptools.zip_members lists the name, size and crc32 of each member once per archive revision. The site lookup and cards, the gap report, the pack check, the romset importer, the recipe identification and build, provenance, derivations and the atom pool read it instead of opening each archive again. Each reader also tested a .zip suffix and skipped the .variants/ copies (x.zip.1a2b3c4d): the site lookup listed no member of a copy, the gap report's member index never saw one, the pack check never compared a copy's members, and the pack builders copied a copy without its CRC test. They now use is_archive_path. The inner ROM index of the resolver reads copies too, and a copy answers only for a member no primary holds.
This commit is contained in:
1 parent
331f244aac
commit
74fcdd2bc5
16 files changed
+213
-103
No files matched your search
@@ -17,6 +17,7 @@ from packs.crossref import FileConsumers
|
||||
from romrecipes.romsets import dat_snapshots, usable_recipe
|
||||
from sitegen import markup, wanted as sitewanted
|
||||
from core.paths import REPO_ROOT
|
||||
from core.ziptools import zip_members
|
||||
from model.mamerelease import tag_version
|
||||
from sitegen.fields import search_excluded
|
||||
from sitegen.install import manifest_systems, platform_display
|
||||
@@ -377,9 +378,7 @@ def _romset_line(f: dict) -> str:
|
||||
if not recipes or not path.is_file():
|
||||
return ""
|
||||
try:
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
held = tuple(sorted((info.filename, f"{info.CRC:08x}")
|
||||
for info in archive.infolist() if not info.is_dir()))
|
||||
held = tuple(sorted((member.name, member.crc32) for member in zip_members(path)))
|
||||
except (OSError, zipfile.BadZipFile) as exc:
|
||||
print(f" WARNING: {path}: {exc}", file=sys.stderr)
|
||||
return ""
|
||||
|
||||
@@ -19,6 +19,7 @@ from packs.crossref import FileConsumers
|
||||
from sitegen.cards import PROVENANCE_LABELS, emulator_card_anchor, emulator_file_anchors
|
||||
from sitegen.config import SITE_URL
|
||||
from core.paths import REPO_ROOT
|
||||
from core.ziptools import is_archive_path, zip_members
|
||||
from sitegen.render import card_anchor, code_span, slugify_anchor, card_page, emulator_card_page
|
||||
from sitegen.write import write_if_changed
|
||||
|
||||
@@ -326,19 +327,17 @@ def _archive_member_records(entry: dict, sha1: str, url: str,
|
||||
no record. The record leads to the archive's card and names it.
|
||||
"""
|
||||
path = root / str(entry.get("path", ""))
|
||||
if path.suffix.lower() != ".zip" or not path.is_file():
|
||||
if not is_archive_path(path.name) or not path.is_file():
|
||||
return []
|
||||
try:
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
members = [(info.filename, info.CRC) for info in archive.infolist()
|
||||
if not info.is_dir()]
|
||||
members = zip_members(path)
|
||||
except (OSError, zipfile.BadZipFile) as exc:
|
||||
print(f" WARNING: {path}: members unreadable ({exc})", file=sys.stderr)
|
||||
return []
|
||||
return [{"value": f"{crc:08x}", "algorithm": "crc32", "layer": "archive-member",
|
||||
"name": member.rsplit("/", 1)[-1], "archive": str(entry.get("name", "")),
|
||||
return [{"value": member.crc32, "algorithm": "crc32", "layer": "archive-member",
|
||||
"name": member.name.rsplit("/", 1)[-1], "archive": str(entry.get("name", "")),
|
||||
"sha1": sha1, "url": url}
|
||||
for member, crc in members]
|
||||
for member in members]
|
||||
|
||||
|
||||
def _collection_lookup_records(
|
||||
|
||||
Reference in new issue
Block a user