fix: vary a primary only with its own copies

Campaign.variant_files listed every .variants/ copy the database named
after the entry, so QUASI88's PC-88 font.rom was varied with a PC-98
font filed under the same name. resolve.localfile.variant_copies keeps
the copies in the primary's own .variants/ folder that pass the entry's
declared hashes and shape checks; the campaign reads it.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 21:42:19 +01:00
1 parent cdf0aa6774
commit 6f3500d8c8
4 files changed
+149 -12

No files matched your search

+3 -12
View File
@@ -31,6 +31,7 @@ from probes.cores import Core, Cores
from probes.entries import (
entry_dest,
held_file,
held_variants,
is_bios,
profile_digest,
region_matches,
@@ -178,18 +179,8 @@ class Campaign:
return held_file(entry, self.db, self.paths.root)
def variant_files(self, entry: dict, primary: Path) -> list[Path]:
"""The .variants/ copies of an entry's file the collection holds."""
names = [entry["name"], *(entry.get("aliases") or ())]
out = []
index = self.db.get("indexes", {}).get("by_name", {})
for name in names:
for sha1 in index.get(name, ()):
path = (self.db["files"].get(sha1) or {}).get("path", "")
if "/.variants/" in path:
local = self.paths.root / path
if local.is_file() and local.resolve() != primary.resolve() and local not in out:
out.append(local)
return out
"""The .variants/ copies standing in for an entry's primary."""
return held_variants(entry, self.db, self.paths.root, primary)
# -- guards ---------------------------------------------------------------
+12
View File
@@ -35,6 +35,18 @@ def held_file(entry: dict, db: dict, root: Path) -> Path | None:
return local if local.is_file() else None
def held_variants(entry: dict, db: dict, root: Path, primary: Path) -> list[Path]:
"""The .variants/ copies standing in for the primary held_file chose, in
the checkout at root."""
from resolve.localfile import variant_copies
hint = entry.get("path") if isinstance(entry.get("path"), str) else ""
stored = primary.relative_to(root) if primary.is_relative_to(root) else primary
with working_directory(root):
paths = variant_copies(entry, db, str(stored), dest_hint=hint or "")
return [path if path.is_absolute() else root / path for path in map(Path, paths)]
def entry_dest(entry: dict) -> str:
"""Where the core reads the entry, relative to its system directory."""
path = entry.get("path")