mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-25 03:00:23 +00:00
fix: move models disk cache from /dev/shm to STATE_DIR for per-instance isolation (#1064)
Using /dev/shm caused cross-instance cache pollution: any server started on a different port (QA harness on 8789, test runs) would write its own provider set to the shared file, and the production server on 8787 would load it on next restart — showing only OpenRouter (or whatever the test environment had configured) instead of the real provider list. Moving the cache file to STATE_DIR / "models_cache.json" gives each server instance its own isolated cache (each port uses a different HERMES_WEBUI_STATE_DIR). Also fixes macOS/Windows portability where /dev/shm does not exist. Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com>
This commit is contained in:
+6
-2
@@ -1104,7 +1104,11 @@ _provider_models_invalidated_ts: dict[str, float] = {} # provider_id -> timesta
|
||||
# config.yaml changes. A TTL is still used as a fallback in case the invalidation
|
||||
# signal is somehow missed, but the cache will always be warm after the first
|
||||
# page load following a server start.
|
||||
_models_cache_path = Path("/dev/shm") / "hermes_webui_models_cache.json"
|
||||
# Cache file lives inside STATE_DIR so each server instance (different
|
||||
# HERMES_WEBUI_STATE_DIR / port) has its own file and test runs never
|
||||
# pollute the production server's cache. Also works on macOS and Windows
|
||||
# where /dev/shm does not exist.
|
||||
_models_cache_path = STATE_DIR / "models_cache.json"
|
||||
|
||||
|
||||
def _delete_models_cache_on_disk() -> None:
|
||||
@@ -1150,7 +1154,7 @@ def invalidate_models_cache():
|
||||
not immediately reload a stale disk snapshot and skip the fresh build.
|
||||
This is essential for test isolation: without the disk delete, tests
|
||||
that call invalidate_models_cache() still get back the previous test's
|
||||
result from /dev/shm because the disk hit is checked before the memory
|
||||
result from the disk cache because the disk hit is checked before the memory
|
||||
cache rebuild runs.
|
||||
"""
|
||||
global _cache_build_in_progress, _available_models_cache, _available_models_cache_ts, _cache_build_cv
|
||||
|
||||
Reference in New Issue
Block a user