Git adding case insenstiive
This commit is contained in:
@@ -25,6 +25,35 @@ def _read_json(path: Path) -> Any:
|
||||
return json.loads(text) if text else {}
|
||||
|
||||
|
||||
def _resolve_case_insensitive(path: Path) -> Path:
|
||||
"""Return the real on-disk path, resolving each component case-insensitively.
|
||||
|
||||
On case-insensitive filesystems (macOS) paths just work. On case-sensitive
|
||||
ones (Linux/WSL) a mismatch between project.json and the actual directory
|
||||
name causes a FileNotFoundError. This walks each component and picks the
|
||||
first directory entry whose name matches case-insensitively, returning the
|
||||
corrected path. If the path already exists, it is returned unchanged.
|
||||
"""
|
||||
if path.exists():
|
||||
return path
|
||||
|
||||
resolved = path.anchor and Path(path.anchor) or Path(".")
|
||||
for part in path.parts[len(Path(path.anchor).parts):]:
|
||||
if (resolved / part).exists():
|
||||
resolved = resolved / part
|
||||
else:
|
||||
try:
|
||||
match = next(
|
||||
(p for p in resolved.iterdir() if p.name.lower() == part.lower()),
|
||||
None,
|
||||
)
|
||||
except (OSError, NotADirectoryError):
|
||||
match = None
|
||||
resolved = match if match else (resolved / part)
|
||||
|
||||
return resolved
|
||||
|
||||
|
||||
def parse_manuscript(
|
||||
project_path: Path,
|
||||
) -> tuple[str, list[str], list[tuple[int, str]], list[Citation]]:
|
||||
@@ -267,6 +296,9 @@ def parse_slides(
|
||||
else:
|
||||
local_slides_path = project_path / "slides.json"
|
||||
|
||||
# Resolve case-insensitively before cache lookup (handles Mac vs WSL casing).
|
||||
local_slides_path = _resolve_case_insensitive(local_slides_path)
|
||||
|
||||
# Try cache fallback for reading JSON
|
||||
slides_path, _ = resolve_with_cache(local_slides_path, project_path)
|
||||
if not slides_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user