DAV PUT: check the size an item is charged, not its body (#499) #508

Merged
jcoffey-dev merged 1 commits from fix/dav-put-charged-size into main 2026-11-20 20:10:40 +00:00
1 Commits
Author SHA1 Message Date
jcoffey-dev 47784bec2b DAV PUT: check the size an item is charged, not its body (#499)
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 23m27s
Part of the inbuxa/inbuxa-admin#257 remediation (Refs inbuxa/inbuxa-admin#257).

A CalDAV, CardDAV or WebDAV PUT checked the account's quota, and its
tenant's, against the bare body length, while the item is charged
more: its names, properties and record as well. So a PUT that fit by
body length went past the limit, by a few hundred bytes per item for
an event. Creating and updating events, cards and files now check the
size the item is charged, the same figure the usage counters move by.

A file's check now comes before its blob is written, so a refused PUT
stores nothing. A new item is checked even when its body is empty,
since it's still charged for the rest.

Tests: the webdav PUT quota loop now checks usage never goes past the
quota (instead of expecting success whenever the body fits), giving
each type its own room since deleted items stay counted while kept;
and a PUT with room for its body but not for its charge is refused,
leaving usage as it was. Failed before the fix (a file PUT went past
the quota; an edge PUT was created).

Refs #499
2026-11-20 12:41:08 -07:00