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

@@ -42,3 +42,16 @@ async def init_db():
await conn.execute(text(col_def))
except Exception:
pass # Column already exists
# Seed default cleanup settings (only if not already set)
defaults = {
"cleanup_enabled": "true",
"cleanup_retention_minutes": "10080", # 7 days
"cleanup_storage_limit_pct": "80",
"cleanup_last_run": "",
"cleanup_last_result": "",
}
for k, v in defaults.items():
await conn.execute(text(
"INSERT OR IGNORE INTO app_settings (key, value, updated_at) VALUES (:k, :v, datetime('now'))"
), {"k": k, "v": v})