pub async fn create(
pool: &PgPool,
vault: &Vault,
actor: &Actor,
new: NewSession,
max_bytes: u64,
) -> AppResult<UploadSession>Expand description
Starts an upload into a revision the actor has checked out. Refuses it early when the file cannot be stored anyway: too large, not checked out, or a stated base that the server file has moved on from.
§Invariants
- Permission: with a revision: CAD editor in the project group with the
revision in work and checked out by the actor (
files::ensure_can_attach; hidden = 404, 403 / 409 otherwise). Without one (new-item session): only the editor role, nobaseallowed; the session can only joinitems::create_with_files, which checks the project group (including restricted groups). The session belongs to the actor alone. - Locks: the actor’s user row (
FOR NO KEY UPDATE), which serialises the quota check: at most 16 unexpired sessions per user (409); the announced size must fit the storage quotas (413,services::quotas). - Steps: the staging file is created before the commit and removed again when the commit fails.
- Audit, notifications, webhooks: none.
- Atomic: one transaction for the session row.