fix: one size predicate, size_options retired

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Abdessamad DerrazandClaude Opus 5.5 committed 2026-10-05 02:51:13 +02:00
1 parent a090e64336
commit 5816562bf6
16 files changed
+115 -61

No files matched your search

+10 -6
View File
@@ -64,6 +64,15 @@ def name_match_size_ok(file_entry: dict, candidate_size: int | None) -> bool:
validation = validation.get("core", [])
if "size" not in (validation or []) or candidate_size is None:
return True
return size_fits(file_entry, candidate_size)
def size_fits(file_entry: dict, candidate_size: int) -> bool:
"""Whether a size is one the entry declares.
``size`` is an exact size or the list of sizes the code accepts; it
outranks a ``min_size``/``max_size`` range. Nothing declared fits all.
"""
declared = file_entry.get("size")
if declared is not None:
allowed = declared if isinstance(declared, list) else [declared]
@@ -450,16 +459,11 @@ def _resolve_agnostic(file_entry: dict, files_db: dict, has_strong_hash: bool):
prefix = file_entry.get("agnostic_path_prefix", "")
if not prefix:
return None
min_size = file_entry.get("min_size", 0)
max_size = file_entry.get("max_size", float("inf"))
exact_size = file_entry.get("size")
if exact_size and not min_size:
min_size = max_size = exact_size
for _sha1, entry in files_db.items():
path = entry.get("path", "")
if not path.startswith(prefix):
continue
if min_size <= entry.get("size", 0) <= max_size and os.path.exists(path):
if size_fits(file_entry, entry.get("size", 0)) and os.path.exists(path):
return path, "agnostic_fallback"
return None
+21 -15
View File
@@ -57,6 +57,7 @@ from common import (
resolve_local_file,
sanitize_pack_path,
select_emulator_profiles,
size_fits,
yaml_load,
)
import packresolve
@@ -65,6 +66,7 @@ import slot as slot_mod
import slots
import split_pack
from deterministic_zip import _FIXED_DATE_TIME, rebuild_zip_deterministic
from largefiles import asset_name
from nativemode import (
digest_algorithm,
hash_mismatch_excludes_file,
@@ -847,14 +849,9 @@ def generate_pack(
_path = _entry.get("path", "")
if _path:
_prefix = _path.rsplit("/", 1)[0] + "/"
_min = _ef.get("min_size", 0)
_max = _ef.get("max_size", float("inf"))
if _ef.get("size") and not _min:
_min = _ef["size"]
_max = _ef["size"]
for _s, _e in files_db.items():
if _e.get("path", "").startswith(_prefix):
if _min <= _e.get("size", 0) <= _max:
if size_fits(_ef, _e.get("size", 0)):
if os.path.exists(_e["path"]):
local_path = _e["path"]
agnostic_path = _prefix
@@ -2765,12 +2762,23 @@ def _is_release_asset(local_path: str, repo_root: str) -> bool:
is still served by the repository, and announcing it as a release asset
sends the installer to an asset nobody uploaded.
"""
gitignore = _load_gitignore_entries(repo_root)
return _repo_relative(local_path, repo_root) in _load_gitignore_entries(repo_root)
def _repo_relative(local_path: str, repo_root: str) -> str:
try:
rel = os.path.relpath(local_path, repo_root)
return os.path.relpath(local_path, repo_root)
except ValueError:
rel = ""
return rel in gitignore
return ""
def _release_asset_name(local_path: str, repo_root: str) -> str:
"""The large-files asset install.py downloads for a gitignored file."""
registered = [
entry for entry in _load_gitignore_entries(repo_root)
if entry.startswith("bios/")
]
return asset_name(_repo_relative(local_path, repo_root), registered)
def _get_repo_path(sha1: str, db: dict) -> str:
@@ -2880,9 +2888,7 @@ def _manifest_core_entries(
if _is_release_asset(local_path or "", repo_root):
entry["storage"] = "release"
entry["release_asset"] = (
os.path.basename(local_path) if local_path else fe["name"]
)
entry["release_asset"] = _release_asset_name(local_path, repo_root)
manifest_files.append(entry)
omitted_by_destination.pop(full_dest, None)
@@ -3117,8 +3123,8 @@ def generate_manifest(
if is_release_asset:
entry["storage"] = "release"
entry["release_asset"] = (
os.path.basename(local_path) if local_path else file_entry["name"]
entry["release_asset"] = _release_asset_name(
local_path, repo_root
)
manifest_files.append(entry)
-5
View File
@@ -1976,7 +1976,6 @@ def _render_emulator_file(
fpattern = f.get("pattern", "")
region_check = f.get("region_check")
size_note = f.get("size_note", "")
size_options = f.get("size_options", [])
size_range = f.get("size_range", "")
badges = _file_badges(f, in_repo)
@@ -2062,10 +2061,6 @@ def _render_emulator_file(
details.append(f"Region check: {'yes' if region_check else 'no'}")
if size_note:
details.append(f"Size note: {size_note}")
if size_options:
details.append(
f"Size options: {', '.join(_fmt_size(s) for s in size_options)}"
)
if size_range:
details.append(f"Size range: {size_range}")
+2 -10
View File
@@ -12,6 +12,7 @@ from common import resolution_is_hash_exact
from common import resolve_local_file
from common import runs_standalone
from common import sanitize_pack_path
from common import size_fits
def _emulator_systems_index(emu_profiles: dict | None) -> dict[str, list[str]]:
"""Map both the profile key and its display name to the profile's systems.
@@ -213,21 +214,12 @@ def _agnostic_scan_extras(
if ambiguous and agnostic_votes.get(path_prefix, 0) < 2:
continue
# Size criteria from the file entry
min_size = f.get("min_size", 0)
max_size = f.get("max_size", float("inf"))
exact_size = f.get("size")
if exact_size and not min_size:
min_size = exact_size
max_size = exact_size
# Scan DB for all files under this prefix matching size
for sha1, entry in files_db.items():
path = entry.get("path", "")
if not path.startswith(path_prefix):
continue
size = entry.get("size", 0)
if not (min_size <= size <= max_size):
if not size_fits(f, entry.get("size", 0)):
continue
scan_name = entry.get("name", "")
if not scan_name: