Skip to main content

Module blossom_capabilities

Module blossom_capabilities 

Source
Expand description

Per-(server, mime, encrypted) Blossom capability cache and routing.

Uploads report outcomes here; rank_servers() reorders the enabled list so known-good servers are tried first.

Structs§

CapabilityEntry
CapabilityState
Per-server snapshot used for tier classification.

Constants§

OUTCOME_ACCEPTED
OUTCOME_REJECTED_MIME
OUTCOME_SIZE_ONLY
Seeded by a 413-only rejection (no successful upload yet). Kept distinct from ACCEPTED so the UI doesn’t claim an empty accepted state.
STALE_AFTER_SECS
Rows older than this are routed as “unknown” and re-probed. Server policies drift (limit bumps, MIME allow-list edits) so we refresh.

Functions§

any_server_likely_accepts
Pre-flight check: is there any enabled server we haven’t already learned will reject this size/MIME/context? Unknown servers count as “likely accepts” so we stay optimistic.
classify
Pure tier-classification (DB-free, unit-testable). Reorders into known-good → unknown → too-large → MIME-rejected, stable within tier.
has_fresh_capability_for
True iff a row exists for (server, mime, encrypted) and is younger than STALE_AFTER_SECS. Used by the probe scheduler to skip rows we already have current data for.
is_mime_rejection
Classify an upload error as a permanent MIME rejection.
is_size_rejection
HTTP 413 = “blob exceeds size cap”. Drives min_rejected_size.
list_for_server
All rows for server_url, most-recent first. Renders the info dialog.
purge_server
Drop every cached row for server_url. Called on hard-remove so a later re-add starts with a clean slate.
rank_servers
Reorder servers for an upload of (mime, encrypted, size_bytes).
record_accepted
Record a successful upload. Bumps max_accepted_size; clears min_rejected_size if reality contradicts it (the old rejection was a flake, not a policy). session pins the write to the account that started the upload so a mid-flight swap can’t bleed.
record_rejected_mime
Mark this (server, mime, encrypted) triple as MIME-rejected. Future uploads route around the server.
record_rejected_size
Record an HTTP 413. Tracks the smallest rejected size; combined with max_accepted_size this gives pre-flight “too large” feedback. Outcome is SIZE_ONLY (not REJECTED_MIME) — smaller blobs of the same MIME may still succeed.