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

+8 -6
View File
@@ -14,7 +14,7 @@ from pathlib import Path
from core.artifacts import set_plain_mode
from core.deterministic_zip import FIXED_DATE_TIME
from core.hashing import compute_hashes
from core.paths import sanitize_pack_path
from core.paths import comparable_destination, sanitize_pack_path
from packs.paths import has_path_conflict, register_path, placement_block
@@ -145,7 +145,7 @@ class Placed:
tree walk all place files through this one record.
``content``, when given, records the sha1 of what each taken path holds,
keyed by its lowercased destination: a case twin carrying the same
keyed by its folded destination: a case twin carrying the same
bytes serves the core on a filesystem that folds the names.
"""
@@ -159,16 +159,18 @@ class Placed:
self.destinations.add(dest)
register_path(dest, self.destinations, self.parents)
if self.fold:
self.lower.add(dest.lower())
self.lower.add(comparable_destination(dest))
if self.content is not None:
self.content[dest.lower()] = sha1
self.content[comparable_destination(dest)] = sha1
def content_at(self, dest: str) -> str | None:
"""The sha1 recorded for the path a destination folds onto."""
return (self.content or {}).get(dest.lower())
return (self.content or {}).get(comparable_destination(dest))
def holds(self, dest: str) -> bool:
return dest in self.destinations or (self.fold and dest.lower() in self.lower)
return dest in self.destinations or (
self.fold and comparable_destination(dest) in self.lower
)
def conflicts(self, dest: str) -> bool:
return has_path_conflict(dest, self.destinations, self.parents)
+2 -2
View File
@@ -9,7 +9,7 @@ from __future__ import annotations
from collections.abc import Iterable
from dataclasses import dataclass
from core.paths import sanitize_pack_path
from core.paths import comparable_destination, sanitize_pack_path
from resolve.validation import read_from_save_dir
@@ -177,7 +177,7 @@ def placement_block(
"""
if dest in seen_files:
return "taken"
if case_insensitive and dest.lower() in seen_lower:
if case_insensitive and comparable_destination(dest) in seen_lower:
return "case_twin"
if has_path_conflict(dest, seen_files, seen_parents):
return "path_conflict"
+2 -1
View File
@@ -10,7 +10,8 @@ from core.hashing import parse_md5_list
from model.profiles import entry_system_ids, lists_files
from resolve import nativemode
from resolve.archives import archive_entry, holds_required_members
from resolve.collisions import accepted_by_all, content_sha1, lists_hashes, comparable_destination
from core.paths import comparable_destination
from resolve.collisions import accepted_by_all, content_sha1, lists_hashes
from resolve.cores import resolve_platform_cores
from resolve.layout import system_dir_path
from resolve.localfile import resolution_is_hash_exact, resolve_local_file