mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 21:38:55 -06:00
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:
1 parent
ca3ff1d4c5
commit
1c978f3083
7 files changed
+27
-23
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user