This commit is contained in:
Mateusz Gruszczyński
2026-05-08 19:37:19 +02:00
parent f76609672d
commit 607d1c59c1
6 changed files with 16 additions and 12 deletions

View File

@@ -169,10 +169,17 @@ def favicon_public_url(domain: str, enabled: bool = True, create: bool = False)
favicon_path(clean, enabled=True)
cached = _cached_favicon(clean)
now = _now_epoch()
if not cached or now - float(cached.get("updated_epoch") or 0) >= FAVICON_CACHE_TTL_SECONDS:
return ""
path = Path(str(cached.get("file_path") or ""))
if not path.exists() or not path.is_file():
path = None
if cached and now - float(cached.get("updated_epoch") or 0) < FAVICON_CACHE_TTL_SECONDS:
cached_path = Path(str(cached.get("file_path") or ""))
if cached_path.exists() and cached_path.is_file():
path = cached_path
if path is None:
# Note: Existing symlinked .ico files are still linked directly even when the DB favicon row is missing or stale.
direct_path = FAVICON_DIR / f"{_safe_filename(clean)}.ico"
if direct_path.exists() and direct_path.is_file():
path = direct_path
if path is None:
return ""
try:
rel = path.resolve().relative_to(FAVICON_DIR.resolve())