Add DELETE /api/admin/backup/{filename} and delete button in Settings

This commit is contained in:
IT狗
2026-07-21 13:14:56 +08:00
parent e531cea8a4
commit c1b1d6f35b
2 changed files with 29 additions and 0 deletions
+13
View File
@@ -1929,6 +1929,19 @@ async def restore_backup(
return {"restored": filename, "auto_backup": auto_dst.name if src.exists() else None}
@app.delete("/api/admin/backup/{filename}")
async def delete_backup(
filename: str,
current_user: User = Depends(get_current_admin),
):
"""Delete a backup file."""
fp = BACKUP_DIR / filename
if not fp.exists() or ".." in filename:
raise HTTPException(status_code=404, detail="Backup not found")
fp.unlink()
return {"deleted": filename}
@app.post("/api/admin/reset/{section}")
async def reset_section(
section: str,