mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-25 02:57:52 -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
@@ -40,6 +40,7 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import IO
|
||||
|
||||
from core.ziptools import is_archive_path, zip_members
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
@@ -116,14 +117,13 @@ def collection_archives(db: dict) -> tuple[set[str], ByMembers]:
|
||||
for entry in db.get("files", {}).values():
|
||||
path = Path(entry.get("path", ""))
|
||||
name = variant_base_name(path.name)
|
||||
if not name.lower().endswith(".zip") or not path.is_file():
|
||||
if not is_archive_path(path.name) or not path.is_file():
|
||||
continue
|
||||
try:
|
||||
with zipfile.ZipFile(path) as archive:
|
||||
held = [
|
||||
{"name": info.filename, "crc32": f"{info.CRC:08x}"}
|
||||
for info in archive.infolist() if not info.is_dir()
|
||||
]
|
||||
held = [
|
||||
{"name": member.name, "crc32": member.crc32}
|
||||
for member in zip_members(path)
|
||||
]
|
||||
except (OSError, zipfile.BadZipFile) as exc:
|
||||
print(f" UNREADABLE: {path}: {exc}", file=sys.stderr)
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user