-
Stefy Lanza (nextime / spora ) authored
Capability detection is already name-based (microsecond-fast), so caching it wouldn't help — the real cost is huggingface_hub.scan_cache_dir() + the per-file size sums walking the whole cache. So instead of re-walking on a TTL, the cached-models/cache-stats layer now computes a cheap change-signature (the names + mtimes of the top-level model dirs/files — a handful of stat() calls) and only does the expensive scan when that signature changes. Unchanged caches return the last result instantly and never re-walk; a change refreshes in the background. A long 600s backstop TTL still re-scans occasionally. Mutating ops reset the signature. Net: the models page is instant on every load and the background refresh only runs when models are actually added/removed/downloaded. Verified: unchanged signature → 0 rescans; changed signature → one background rescan. Co-Authored-By:
Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011DDv7BchtZQWsnPG6Jm49m
0bc9ba76