disable archive in demo mode

This commit is contained in:
Gamosoft
2026-08-25 13:58:31 +02:00
parent 1820b861b3
commit f62f5fff66
2 changed files with 11 additions and 1 deletions
+9 -1
View File
@@ -1617,7 +1617,7 @@ def download_folder_archive(request: Request, folder: str = ""):
parsed, which means media a note links to from a *different* folder is not
pulled in — exporting a folder gives you that folder.
Symlinks, dot-files and dot-directories are skipped.
Symlinks, dot-files and dot-directories are skipped. Disabled in demo mode.
Query Parameters:
folder: Folder to archive, relative to the vault root. Omit it (or pass an
@@ -1626,6 +1626,14 @@ def download_folder_archive(request: Request, folder: str = ""):
Returns:
A zip file, with paths inside it relative to the requested folder.
"""
# Notes can be written in demo mode, so without this anyone could upload
# attachments and then ask for a zip of the whole vault ten times a minute, on
# the demo's bandwidth. Nothing about trying the app out needs its content
# downloaded. This also puts the rate limit above out of reach, since limits
# only apply in demo mode; it stays for the day this guard is lifted.
if DEMO_MODE:
raise HTTPException(status_code=403, detail="Archiving is disabled in demo mode")
notes_dir = config['storage']['notes_dir']
folder_path = (folder or '').strip().strip('/')
+2
View File
@@ -537,6 +537,7 @@ Unlike the HTML export above, this returns the **raw files** exactly as they are
**Response:**
- `200``application/zip`, named after the folder (or the app name for a whole-vault archive). Paths inside the archive are relative to the requested folder
- `403` — the instance is running in demo mode, where archiving is disabled
- `404` — folder does not exist, is not a directory, or contains no files
- `413` — the files exceed `ARCHIVE_MAX_FOLDER_MB` (default 500). Archive a subfolder or raise the limit
@@ -546,6 +547,7 @@ Unlike the HTML export above, this returns the **raw files** exactly as they are
- Symlinks are skipped, files and directories alike, so an archive can never contain anything from outside the vault
- Already-compressed files (images, audio, video, PDFs) are stored rather than deflated, which is roughly six times faster for the same size
- The response sets `Content-Encoding: identity` so the archive is not gzipped a second time in transit and keeps its `Content-Length`
- Disabled entirely when `DEMO_MODE` is on: notes can be written on a demo, so an open archive route would let anyone upload attachments and then pull the whole vault repeatedly on the host's bandwidth
**Rate Limit:** 10 requests/minute