fix(kvb-org-organize): skip a missing cache root in the cache trim

cache_files walked every cache_dirs entry with os.fwalk, which raises FileNotFoundError for a folder that does not exist (~/.cache/ms-playwright on this host), so cleanup --caches crashed and trim_caches never ran at disk stage warn. A root that cannot be walked is now skipped and the other roots are still trimmed.

🎯 Fix: 95 %
💥 Break: 2 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-11 09:44:40 +00:00
1 parent c3ab6b7e18
commit 8f942ff071
2 files changed
+23 -10

No files matched your search

+13 -10
View File
@@ -1047,16 +1047,19 @@ def cache_files(dirs: list[str]) -> list[tuple[float, int, str, str]]:
files = []
seen: set[tuple[int, int]] = set()
for root in map(os.path.expanduser, dirs):
for base, _, names, fd in os.fwalk(root, follow_symlinks=False):
for name in names:
try:
st = os.stat(name, dir_fd=fd, follow_symlinks=False)
except OSError:
continue
if (st.st_dev, st.st_ino) in seen:
continue
seen.add((st.st_dev, st.st_ino))
files.append((st.st_atime, st.st_blocks * 512, os.path.join(base, name), root))
try:
for base, _, names, fd in os.fwalk(root, follow_symlinks=False):
for name in names:
try:
st = os.stat(name, dir_fd=fd, follow_symlinks=False)
except OSError:
continue
if (st.st_dev, st.st_ino) in seen:
continue
seen.add((st.st_dev, st.st_ino))
files.append((st.st_atime, st.st_blocks * 512, os.path.join(base, name), root))
except OSError:
continue
return files