mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 19:38:52 -06:00
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:
1 parent
1c978f3083
commit
8bc1fcb5db
9 files changed
+55
-60
No files matched your search
@@ -11,6 +11,7 @@ from core.hashing import compute_hashes
|
||||
from core.paths import BIOS_DIR, REPO_ROOT
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.alternatives import set_requirements, settle_sets, slot_set_keys
|
||||
from model.database import sha1_at
|
||||
from model.profiles import (
|
||||
ProfileSelectionError,
|
||||
entry_serves_systems,
|
||||
@@ -207,7 +208,6 @@ class _EmulatorPack:
|
||||
# The emulator pack walks profiles in name order and keeps the first
|
||||
# file at a path, folding case: a later profile's different file there
|
||||
# (zesarux pentagon.rom after speccy's PENTAGON.ROM) is not in the pack.
|
||||
sha1_by_path: dict = field(init=False)
|
||||
# Destination -> (file packed there, its profile, the path as written).
|
||||
# Archives and data trees take paths too, before and after the loose
|
||||
# files of their profile, as the pack writes them.
|
||||
@@ -215,11 +215,6 @@ class _EmulatorPack:
|
||||
taken: Placed = field(default_factory=lambda: Placed(True))
|
||||
content_ids: dict[str, str | None] = field(default_factory=dict)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
self.sha1_by_path = {
|
||||
entry.get("path"): sha1 for sha1, entry in self.db.get("files", {}).items()
|
||||
}
|
||||
|
||||
def pending(self, entry: dict, local_path: str | None, status: str) -> tuple[str | None, str]:
|
||||
from resolve.packfiles import pending_release_asset, run_is_offline
|
||||
|
||||
@@ -236,7 +231,7 @@ class _EmulatorPack:
|
||||
if not path:
|
||||
return None
|
||||
if path not in self.content_ids:
|
||||
self.content_ids[path] = self.sha1_by_path.get(path) or (
|
||||
self.content_ids[path] = sha1_at(self.db, path) or (
|
||||
compute_hashes(path)["sha1"] if os.path.isfile(path) else None
|
||||
)
|
||||
return self.content_ids[path]
|
||||
|
||||
Reference in new issue
Block a user