refactor: fold destinations with one rule

comparable_destination moves to core.paths. Placed, placement_block,
the shared group merge of model.platforms and LauncherPlace.fold read it
in place of their own lower(). It also trims surrounding blanks and
slashes and folds with casefold: no destination, collection path or
launcher name differs under those rules today, so the output is the
same.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent ca3ff1d4c5
commit 1c978f3083
7 files changed
+27 -23

No files matched your search

+1 -10
View File
@@ -7,21 +7,12 @@ import zlib
from dataclasses import dataclass, field
from core.hashing import compute_hashes, parse_hash_list, parse_md5_list
from core.paths import comparable_destination
from core.ziptools import check_inside_zip
from resolve.localfile import resolve_local_file, variant_base_name
from resolve.packfiles import records_by_path, preferred_entries
def comparable_destination(destination: str, fold: bool = True) -> str:
"""Comparable form of a destination, since layers write it differently.
Case is folded only where the platform's filesystem folds it: on Linux
RetroDECK ships bios/DISK.ROM and bios/disk.rom side by side.
"""
cleaned = destination.strip().strip("/").replace("\\", "/")
return cleaned.casefold() if fold else cleaned
@dataclass
class Collision:
"""One destination a platform fills with two different files."""
+2 -2
View File
@@ -25,7 +25,7 @@ from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, outer_lay
from model.profiles import lists_files
from resolve.content import name_match_size_ok
from resolve.localfile import resolve_local_file
from core.paths import sanitize_pack_path
from core.paths import comparable_destination, sanitize_pack_path
from core.paths import REPO_ROOT
# The kinds whose names say which file the launcher opens. A link of a named
@@ -74,7 +74,7 @@ class LauncherPlace:
passes_to: str = ""
def fold(self, name: str) -> str:
return name.lower() if self.case_insensitive else name
return comparable_destination(name, self.case_insensitive)
def basenames(self) -> set[str]:
return {self.fold(p.rsplit("/", 1)[-1]) for p in self.paths}