feat: match settings card width to ops map and add backup download
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import re
|
||||
import time
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi.responses import FileResponse
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from apps.api.auth import auth_disabled, require_auth, verify_credentials
|
||||
@@ -150,6 +151,22 @@ def create_backup(body: BackupActionBody) -> dict:
|
||||
}
|
||||
|
||||
|
||||
@router.get("/backup/download/{backup_name}")
|
||||
def download_backup(backup_name: str) -> FileResponse:
|
||||
s = get_settings()
|
||||
try:
|
||||
path = resolve_backup_file(s.backup_dir_path, backup_name.strip())
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e)) from e
|
||||
except FileNotFoundError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e)) from e
|
||||
return FileResponse(
|
||||
path=str(path),
|
||||
filename=path.name,
|
||||
media_type="application/octet-stream",
|
||||
)
|
||||
|
||||
|
||||
@router.post("/restore")
|
||||
def restore_backup(body: RestoreBody) -> dict:
|
||||
_verify_password_or_401(body.current_password)
|
||||
|
||||
Reference in New Issue
Block a user