refactor: index the database by path once

model.database.record_at and sha1_at read one cached path index with
normpath keys. They replace records_by_path of resolve.packfiles, the
manifest's own sha1 index, the per-call indexes of regionaudit,
emulatorcheck and hidden_extras, and the linear scan of held_record.
resolve_sha1 drops its by_path argument. A path spelled with ./ or a
doubled slash now finds its record everywhere; the database writes none,
so the output is the same.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent 1c978f3083
commit 8bc1fcb5db
9 files changed
+55 -60

No files matched your search

+2 -4
View File
@@ -21,6 +21,7 @@ from collections.abc import Callable, Iterable, Mapping
from dataclasses import dataclass
from core.hashing import parse_hash_list
from model.database import record_at
from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, outer_layout
from model.profiles import lists_files
from resolve.content import name_match_size_ok
@@ -1239,10 +1240,7 @@ def held_record(report: dict, db: dict) -> dict | None:
local, status = resolve_local_file(report, db, dest_hint=report.get("path") or "")
if local is None or status in ("not_found", "hash_mismatch"):
return None
for record in db.get("files", {}).values():
if record.get("path") == local:
return record
return None
return record_at(db, local)
def declared_destinations(config: dict) -> set[str]: