feat: 优化发布清单和安装结构自动识别

This commit is contained in:
2026-07-15 06:33:33 +00:00
parent 0548692db0
commit 4df439b5ce
28 changed files with 1702 additions and 198 deletions
+11
View File
@@ -18,6 +18,7 @@ import minio_tool
from app.api.router import include_api_routes
from app.core.audit import admin_audit_middleware
from app.core.config import configured_path, env_bool, settings
from app.core.security import ensure_default_admin_user
from app.services.crash_api_service import ensure_storage_dirs
from app.services.device_credential_service import verify_device_credential
from app.services.publish_service import UPLOAD_SPOOL_DIR
@@ -54,6 +55,13 @@ async def lifespan(app: FastAPI):
license_columns = {row[1] for row in cur.execute("PRAGMA table_info(licenses)").fetchall()}
if "license_key_cipher" not in license_columns:
cur.execute("ALTER TABLE licenses ADD COLUMN license_key_cipher TEXT NOT NULL DEFAULT ''")
audit_columns = {row[1] for row in cur.execute("PRAGMA table_info(admin_audit_logs)").fetchall()}
if "actor_username" not in audit_columns:
cur.execute("ALTER TABLE admin_audit_logs ADD COLUMN actor_username TEXT NOT NULL DEFAULT ''")
if "actor_roles" not in audit_columns:
cur.execute("ALTER TABLE admin_audit_logs ADD COLUMN actor_roles TEXT NOT NULL DEFAULT ''")
if "auth_type" not in audit_columns:
cur.execute("ALTER TABLE admin_audit_logs ADD COLUMN auth_type TEXT NOT NULL DEFAULT ''")
for app_row in cur.execute("SELECT app_id FROM apps").fetchall():
if not cur.execute("SELECT 1 FROM channels WHERE app_id=? LIMIT 1", (app_row[0],)).fetchone():
cur.executemany(
@@ -72,6 +80,7 @@ async def lifespan(app: FastAPI):
print("===== 数据库初始化完成 =====")
ensure_storage_dirs()
ensure_default_admin_user()
start_minio_if_needed()
yield
@@ -175,6 +184,8 @@ async def auth_middleware(request: Request, call_next):
"/platform-config.json",
"/logo.svg",
"/health",
"/login",
"/refresh-token",
"/api/v1/health",
"/api/v1/crash-reports",
"/api/v1/symbols",