library: hidden segments are never assets
The everything-indexes sweep pulled .thumbs/ cache files in as rows; fixing one sent a thumb path into the dispatcher (unknown asset). One rule, both writers: any path segment starting with a dot is excluded — forks and cache trees alike.
This commit is contained in:
@@ -143,11 +143,11 @@ def _save_library(root: Path, lib: dict) -> None:
|
||||
|
||||
|
||||
def _safe_asset(root: Path, rel: str) -> Path | None:
|
||||
p = (root / rel).resolve()
|
||||
if p.name.startswith("."):
|
||||
# Dotfiles are never assets (AppleDouble forks carry image extensions
|
||||
# but serve resource-fork bytes) — refuse them everywhere at once.
|
||||
if any(part.startswith(".") for part in Path(rel).parts):
|
||||
# Hidden segments are never assets — AppleDouble forks AND cache
|
||||
# trees (.thumbs/) in one rule, refused everywhere at once.
|
||||
return None
|
||||
p = (root / rel).resolve()
|
||||
return p if p.is_file() and str(p).startswith(str(root.resolve())) else None
|
||||
|
||||
|
||||
|
||||
@@ -91,12 +91,13 @@ def classify(relpath: str, slugs: set[str]) -> dict | None:
|
||||
def scan(root: str) -> list[str]:
|
||||
"""All manifestable image paths (relative to root), sorted for stable diffs."""
|
||||
found: list[str] = []
|
||||
for base, _dirs, files in os.walk(root):
|
||||
for base, dirs, files in os.walk(root):
|
||||
# Hidden segments are never assets — one rule covering AppleDouble
|
||||
# forks (._foo.png) AND cache trees (.thumbs/ thumbnails indexed as
|
||||
# library rows sent thumb paths into the fix dispatcher).
|
||||
dirs[:] = [d for d in dirs if not d.startswith(".")]
|
||||
for f in files:
|
||||
if f.startswith("."):
|
||||
# Dotfiles are never assets: `._foo.png` AppleDouble forks ride
|
||||
# along with mac transfers, carry an image extension, and are
|
||||
# resource-fork bytes that render 0x0 in the library.
|
||||
continue
|
||||
ext = os.path.splitext(f)[1].lower()
|
||||
full = os.path.join(base, f)
|
||||
|
||||
Reference in New Issue
Block a user