Handling fs

This commit is contained in:
Anaïs Saraiva
2026-08-15 10:31:52 +02:00
parent f1a8a05417
commit 12d9e99aa2
8 changed files with 64 additions and 17 deletions
+7 -4
View File
@@ -63,7 +63,8 @@ HOST=127.0.0.1 # bind loopback only; the proxy talks to it
PORT=3000
STORAGE_DIR=/opt/filehost/storage
MAX_FILE_SIZE=10GB # must be <= proxy upload limit
FILE_TTL_MS=604800000 # expire files after 1 week
FILE_TTL_MS=172800000 # expire files after 48 hours (hard maximum)
MAX_STORAGE_USAGE=0.5 # block uploads when >50% of the disk is used
RATE_LIMIT_ENABLED=1
TRUST_PROXY=1 # proxy sets X-Forwarded-For
```
@@ -247,6 +248,8 @@ Files in `storage/` are untouched by updates and keep working.
short-lived HMAC-signed cookie (server secret in `storage/.secret`).
- Rate limiting protects the keyed endpoints; `TRUST_PROXY=1` must only be set
when a proxy really sets `X-Forwarded-For`/`CF-Connecting-IP`.
- Files auto-expire after one week (configurable via `FILE_TTL_MS`) and are
swept hourly. Deletion also requires possession of the key
(`DELETE /api/files/:id` with `X-Delete-Key`).
- Files auto-expire after 48 hours (configurable via `FILE_TTL_MS`, hard-capped
at 48h) and are swept hourly. Deletion also requires possession of the key
(`DELETE /api/files/:id` with `X-Delete-Key`).
- Uploads are rejected with `503 try again later` when the storage filesystem is
more than 50% full (configurable via `MAX_STORAGE_USAGE`).