Limit how much room people's files take
All checks were successful
CI / check (push) Successful in 6m41s
CI / deploy (push) Successful in 1m4s

An anonymous person may keep 100 MB of images and sounds, an identified one
500 MB, and one person more by a file_allowance row the operator adds; all
of them together 15 GB, since every file is in the database and in each dump
the server keeps (decided 2026-10-02). Each comes from the environment
(FILE_LIMIT_*_MB), with these defaults, documented in deploy/.env.example.

The server checks when an upload starts, counting unfinished uploads so they
can't fill the disk unnoticed, and again when it finishes, counting what is
kept, so uploads started side by side can't overshoot; a refusal is a
FileLimitExceededException, and an upload refused as it finishes is deleted.
deletePerson deletes the allowance with the person. Migration: the new
table file_allowance, only added.

The app keeps a refused file waiting on the device and stops that round of
uploads; the Anki import warns when a deck's files may not fit in the room
left (asset.usage()).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-02 05:57:57 +02:00
commit ca69f74fd9
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 9884 additions and 20 deletions

View file

@ -28,3 +28,16 @@ GITHUB_CLIENT_SECRET=
# use the instance. Empty: the project's repository, which is right for unmodified code.
# Running modified code, set it to where your modified source is published.
SOURCE_URL=
# How much room people's images and sounds may take on this instance, in MiB. Empty: the
# defaults, 100 for an anonymous person (anonymous accounts are meant to become identified
# ones), 500 for one signed in with GitHub, and 15000 for everyone together (0: no limit
# for everyone together). Every file is in the database, so also in each of the 3 dumps
# this server keeps (and a fourth while a deploy writes its own): files take five times
# their size on the disk. One person may get more than the default; as the operator,
# in deploy/ (their id is their account's, "authUserId"):
# docker compose exec postgres psql -U halkyon_learn -d halkyon_learn -c "INSERT INTO
# file_allowance (\"authUserId\", \"maxBytes\", note) VALUES ('<id>', 2147483648, 'asked by mail')"
FILE_LIMIT_ANONYMOUS_MB=
FILE_LIMIT_IDENTIFIED_MB=
FILE_LIMIT_INSTANCE_MB=

View file

@ -53,6 +53,10 @@ services:
SERVERPOD_PASSWORD_githubClientSecret: ${GITHUB_CLIENT_SECRET:-}
# Where the source of what this instance runs is; empty: the project's.
SOURCE_URL: ${SOURCE_URL:-}
# How much room people's files may take, in MiB; empty: the defaults.
FILE_LIMIT_ANONYMOUS_MB: ${FILE_LIMIT_ANONYMOUS_MB:-}
FILE_LIMIT_IDENTIFIED_MB: ${FILE_LIMIT_IDENTIFIED_MB:-}
FILE_LIMIT_INSTANCE_MB: ${FILE_LIMIT_INSTANCE_MB:-}
depends_on:
postgres:
condition: service_healthy