fix: set version cache to 24hrs
This commit is contained in:
parent
aa91523a09
commit
a9af195485
4 changed files with 14 additions and 6 deletions
|
|
@ -24,6 +24,9 @@ _version_cache: dict = {
|
||||||
"check_failed": False,
|
"check_failed": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cache TTL in seconds (24 hours)
|
||||||
|
VERSION_CACHE_TTL = 24 * 60 * 60
|
||||||
|
|
||||||
|
|
||||||
def get_version() -> str:
|
def get_version() -> str:
|
||||||
"""Read version from pyproject.toml"""
|
"""Read version from pyproject.toml"""
|
||||||
|
|
@ -48,11 +51,16 @@ def get_latest_version_cached(current_version: str) -> tuple[Optional[str], bool
|
||||||
"""
|
"""
|
||||||
global _version_cache
|
global _version_cache
|
||||||
|
|
||||||
# Use cache if available (lives for entire API process lifetime)
|
# Check if cache is still valid (within TTL)
|
||||||
if _version_cache["timestamp"] > 0:
|
cache_age = time.time() - _version_cache["timestamp"]
|
||||||
logger.debug("Using cached version check result")
|
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"]
|
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
|
# Perform version check with strict error handling
|
||||||
try:
|
try:
|
||||||
logger.info("Checking for latest version from GitHub...")
|
logger.info("Checking for latest version from GitHub...")
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ export function SystemInfo() {
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<span className="text-sm font-medium">Status</span>
|
<span className="text-sm font-medium">Status</span>
|
||||||
{config?.hasUpdate ? (
|
{config?.hasUpdate ? (
|
||||||
<Badge variant="default" className="bg-primary">
|
<Badge variant="destructive">
|
||||||
Update Available
|
Update Available
|
||||||
</Badge>
|
</Badge>
|
||||||
) : config?.latestVersion ? (
|
) : config?.latestVersion ? (
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "open-notebook"
|
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"
|
description = "An open source implementation of a research assistant, inspired by Google Notebook LM"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "Luis Novo", email = "lfnovo@gmail.com"}
|
{name = "Luis Novo", email = "lfnovo@gmail.com"}
|
||||||
|
|
|
||||||
2
uv.lock
2
uv.lock
|
|
@ -2208,7 +2208,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "open-notebook"
|
name = "open-notebook"
|
||||||
version = "1.0.8"
|
version = "1.0.9"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "ai-prompter" },
|
{ name = "ai-prompter" },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue