chadtmiller.com/group-host
atmosphere group host
host: blobs, kept while a record references them, served and listed
MergedThis adds blob storage to the host. Bytes go on disk and their metadata and record references go in the database. Writes validate and link blob references, commit events name the blobs, and orphaned blobs are removed. getBlob and listBlobs are added, and a sweep runs hourly. I found no correctness bug that blocks the merge. I did not run the tests or read the checks.
The docs the repository asks for are updated: the design README and the config reference. The transaction logic is sound. Unlinking, relinking and then FORGET_ORPHAN give the right result when one write moves a reference between records. The temporary = 0 guard stops an orphan delete from removing an upload that is still waiting.
Two small robustness points, neither of which should block the merge:
- A re-upload of a temporary blob keeps its old
created_at, so the sweep can remove a blob the client just re-sent. - The
.partfile name is shared by concurrent uploads of identical bytes in one process. If two run at once, one rename can fail with ENOENT and return a 500.
crates/group-host/src/store.rsline 78Outdated
These lines can no longer be read.
On conflict only mime_type is updated, so re-uploading a still-temporary blob does not extend its life. Setting created_at = excluded.created_at when temporary = 1 would fix that.
crates/group-host/src/blobs.rsline 75Outdated
These lines can no longer be read.
The temp name is only the pid. Two simultaneous uploads of the same bytes (same cid) share it, so one rename can fail with ENOENT and surface as a 500. A per-upload counter or random suffix avoids that.
What changes
Blobs, kept as long as a record references them. Bytes live on disk under
DATA_DIR/blobs/<did>/<cid>, each written whole to a temporary name and renamed into place; the database (a third migration) keeps each blob's type, size and whether it is still temporary, and which records reference which blobs.Host::upload_blob(did, bytes, type)keeps an upload as temporary, refusing one overBLOB_UPLOAD_LIMIT(BlobTooLarge, default 50 MiB, as the prototype), and answers the{"$type": "blob", …}reference a record holds it by.#commitevent names its records' blobs inblobs.com.atproto.sync.getBlobserves a referenced blob only, withX-Content-Type-Options: nosniffand a sandboxing CSP;com.atproto.sync.listBlobslists referenced blobs by CID, a page at a time, and since a rev.Why
A group's profile has an avatar and a banner, and its records will carry pictures; the PDS that holds the records holds their blobs. This is the prototype's lifecycle, the reference PDS's on a plain directory.
How it was checked
tests/blobs.rs: an upload not served until a record references it, then served with its headers, listed, and named in the commit's event; a blob two records share kept until both drop it, its file then gone; listBlobs' pages andsince; the size limit, an unknown repo, a record referencing a blob not uploaded, a bad CID; the sweep removing only an untaken upload;blob_refsfinding references at any depth and only blob-typed ones.cargo llvm-covat 100% of lines and functions, clippy clean.Shortcomings
com.atproto.repo.uploadBlobneeds a group's OAuth session, so it comes with signing in; uploads are made from Rust until then. No image route yet (the prototype's/img/<group>/<slot>), which serves from the meta space.