feat: auto cleanup with retention period, storage limit, settings UI

This commit is contained in:
mini
2026-02-18 23:47:33 +08:00
parent 5bc7f8d1df
commit f106763723
7 changed files with 434 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
"""XDL - Twitter/X Video Downloader API."""
import asyncio
import os
from contextlib import asynccontextmanager
from dotenv import load_dotenv
@@ -9,12 +10,19 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.database import init_db
from app.routes import auth, parse, download, admin
from app.services.cleanup import cleanup_loop
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
task = asyncio.create_task(cleanup_loop())
yield
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
app = FastAPI(title="XDL - Video Downloader", version="1.0.0", lifespan=lifespan)