0.37.0: download whole folders (recursive) as a .zip from the file browser

The file browser/editor could only download individual files. Add a
recursive directory download that streams the folder as a zip archive,
on the local host and on every remote agent.

- file_service.archive_dir(): zip a directory recursively into a temp
  file, preserving the folder name as the archive root and empty
  subdirectories; symlinks are skipped (no sandbox escape / loops).
- /api/files/download and /agent/files/download branch on directories
  and return application/zip, cleaning up the temp file afterwards.
- Files page: show the download button for folders too (as <name>.zip).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
menzelj
2026-06-21 19:54:50 +00:00
co-authored by Claude Opus 4.8
parent 5bcec06bbd
commit f1782eca0e
6 changed files with 67 additions and 12 deletions
+7
View File
@@ -20,6 +20,7 @@ from fastapi import (
UploadFile,
)
from fastapi.responses import FileResponse
from starlette.background import BackgroundTask
from pydantic import BaseModel
from sqlmodel import Session
@@ -69,6 +70,12 @@ def download(
path: str = Query(...),
_user: User = Depends(get_current_user),
):
if _guard(file_service.is_dir, path):
tmp, filename = _guard(file_service.archive_dir, path)
return FileResponse(
tmp, filename=filename, media_type="application/zip",
background=BackgroundTask(os.unlink, tmp),
)
real, filename = _guard(file_service.resolve_download, path)
return FileResponse(real, filename=filename, media_type="application/octet-stream")