fix: set version cache to 24hrs

This commit is contained in:
LUIS NOVO 2025-10-19 18:05:04 -03:00
parent aa91523a09
commit a9af195485
4 changed files with 14 additions and 6 deletions

View file

@ -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...")

View file

@ -63,7 +63,7 @@ export function SystemInfo() {
<div className="flex items-center justify-between">
<span className="text-sm font-medium">Status</span>
{config?.hasUpdate ? (
<Badge variant="default" className="bg-primary">
<Badge variant="destructive">
Update Available
</Badge>
) : config?.latestVersion ? (

View file

@ -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"}

View file

@ -2208,7 +2208,7 @@ wheels = [
[[package]]
name = "open-notebook"
version = "1.0.8"
version = "1.0.9"
source = { editable = "." }
dependencies = [
{ name = "ai-prompter" },