From a9af195485c28d367634afe15541de15f9192e67 Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Sun, 19 Oct 2025 18:05:04 -0300 Subject: [PATCH] fix: set version cache to 24hrs --- api/routers/config.py | 14 +++++++++++--- .../(dashboard)/advanced/components/SystemInfo.tsx | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/routers/config.py b/api/routers/config.py index 24de56c..3a9e5d5 100644 --- a/api/routers/config.py +++ b/api/routers/config.py @@ -24,6 +24,9 @@ _version_cache: dict = { "check_failed": False, } +# Cache TTL in seconds (24 hours) +VERSION_CACHE_TTL = 24 * 60 * 60 + def get_version() -> str: """Read version from pyproject.toml""" @@ -48,11 +51,16 @@ def get_latest_version_cached(current_version: str) -> tuple[Optional[str], bool """ global _version_cache - # Use cache if available (lives for entire API process lifetime) - if _version_cache["timestamp"] > 0: - logger.debug("Using cached version check result") + # Check if cache is still valid (within TTL) + cache_age = time.time() - _version_cache["timestamp"] + if _version_cache["timestamp"] > 0 and cache_age < VERSION_CACHE_TTL: + logger.debug(f"Using cached version check result (age: {cache_age:.0f}s)") return _version_cache["latest_version"], _version_cache["has_update"] + # Cache expired or not yet set + if _version_cache["timestamp"] > 0: + logger.info(f"Version cache expired (age: {cache_age:.0f}s), refreshing...") + # Perform version check with strict error handling try: logger.info("Checking for latest version from GitHub...") diff --git a/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx b/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx index d759fce..7916eae 100644 --- a/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx +++ b/frontend/src/app/(dashboard)/advanced/components/SystemInfo.tsx @@ -63,7 +63,7 @@ export function SystemInfo() {
Status {config?.hasUpdate ? ( - + Update Available ) : config?.latestVersion ? ( diff --git a/pyproject.toml b/pyproject.toml index 4d53d0c..2742fbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "open-notebook" -version = "1.0.8" +version = "1.0.9" description = "An open source implementation of a research assistant, inspired by Google Notebook LM" authors = [ {name = "Luis Novo", email = "lfnovo@gmail.com"} diff --git a/uv.lock b/uv.lock index a6987f3..d2b53f3 100644 --- a/uv.lock +++ b/uv.lock @@ -2208,7 +2208,7 @@ wheels = [ [[package]] name = "open-notebook" -version = "1.0.8" +version = "1.0.9" source = { editable = "." } dependencies = [ { name = "ai-prompter" },