fix: 全量修复批量选择、JWT 60min、script-callback 认证与心跳数据流
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+11
-9
@@ -9,6 +9,7 @@ Sensitive values are masked in GET responses.
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
import logging
|
||||
import ipaddress
|
||||
import re
|
||||
import socket
|
||||
@@ -27,6 +28,8 @@ from server.infrastructure.database.ssh_key_preset_repo import SshKeyPresetRepos
|
||||
from server.infrastructure.database.audit_log_repo import AuditLogRepositoryImpl
|
||||
from server.domain.models import PushSchedule, PushRetryJob, PasswordPreset, SshKeyPreset, AuditLog, Admin
|
||||
|
||||
logger = logging.getLogger("nexus.settings")
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
# Settings that cannot be modified via API (encryption consistency)
|
||||
@@ -156,7 +159,6 @@ _MAX_AGE_DAYS = 7 # auto-clean older than 7 days
|
||||
|
||||
def _cleanup_old_wallpapers() -> int:
|
||||
"""Remove wallpapers older than 7 days. Returns count removed."""
|
||||
import time
|
||||
from datetime import datetime, timedelta, timezone
|
||||
cutoff = datetime.now(timezone.utc).replace(tzinfo=None) - timedelta(days=_MAX_AGE_DAYS)
|
||||
removed = 0
|
||||
@@ -166,8 +168,8 @@ def _cleanup_old_wallpapers() -> int:
|
||||
if mtime < cutoff:
|
||||
f.unlink()
|
||||
removed += 1
|
||||
except Exception:
|
||||
pass
|
||||
except OSError as e:
|
||||
logger.debug("Wallpaper cleanup skip %s: %s", f.name, e)
|
||||
return removed
|
||||
|
||||
|
||||
@@ -179,7 +181,6 @@ async def bing_wallpapers():
|
||||
cleans up old files, returns sorted list of local URLs.
|
||||
"""
|
||||
import httpx
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
_WALLPAPER_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -214,10 +215,11 @@ async def bing_wallpapers():
|
||||
if img_resp.status_code == 200:
|
||||
cached.write_bytes(img_resp.content)
|
||||
downloaded += 1
|
||||
except Exception:
|
||||
except httpx.HTTPError as e:
|
||||
logger.debug("Bing image download failed: %s", e)
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
except httpx.HTTPError as e:
|
||||
logger.warning("Bing wallpaper sync failed: %s", e)
|
||||
|
||||
# Cleanup old files
|
||||
_cleanup_old_wallpapers()
|
||||
@@ -227,8 +229,8 @@ async def bing_wallpapers():
|
||||
for f in all_files[_MAX_WALLPAPERS:]:
|
||||
try:
|
||||
f.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
except OSError as e:
|
||||
logger.debug("Wallpaper prune skip %s: %s", f.name, e)
|
||||
|
||||
# Return sorted URLs (newest first)
|
||||
urls = [f"/app/wallpapers/{f.name}" for f in sorted(all_files[:_MAX_WALLPAPERS], key=lambda f: f.name, reverse=True)]
|
||||
|
||||
Reference in New Issue
Block a user