Blobs
Big, immutable things go to one store, src/blob/store.ts (step 2 of
#4481). Its keys are paths and its contents are bytes; it has no other
idea of structure. The refs and metadata that name those bytes stay in
the database.
Two shapes, one store
Storeis the small shape snapshots were written against: put, get, list, names, delete. Snapshots, the mirror and the drill still take exactly this, unchanged (docs/SNAPSHOT.md).BlobStoreis the same store, with what a large file needs:put(key, Blob): aBun.fileis streamed from disk, never read whole into memory. It can be retried, because it is read anew each time.putStream(key, stream): a body of unknown length. A bucket takes it multipart. A directory writes it under a temporary name and renames it into place, so a reader never sees half of it. It is tried only once, because a stream cannot be replayed.size(key),getRange(key, { start, end })andgetStream(key, range?).endis exclusive. A range past the end of the object is empty, and an absent key isundefined, the same answer on a bucket as on a directory.presign(key, { method: "GET" | "PUT", expiresInS }): a URL straight to the bucket, signed locally with no request. A directory has none, so its caller serves the bytes itself.- A storage-class hint on every put:
hot(the default, which sends nothing),infrequent(STANDARD_IA, which R2 and S3 accept) orarchive(DEEP_ARCHIVE, S3 only). It is the fourth argument ofput(key, body, signal?, options?): the third is the abort signal snapshots already pass, so their calls are unchanged.
s3Store (any S3-compatible endpoint: R2, S3, B2) and dirStore are both
BlobStores. withRetries keeps one a BlobStore: sizes, ranges and
opening a stream are retried the way a get is, and a Blob put gets a
deadline that follows its size.
At the boundary
A key with .. or . segments, a leading / or a control byte is
refused. So is a range that is not whole, non-negative bytes in order, and
a presign that is not a GET or PUT valid for 1 s to 7 days. The bucket's
secret never appears in a presigned URL; only its signature does.
Not here yet
Archiving finished run logs and attachments onto the store, big git blobs by OID and the cold-tier lifecycle are later steps of #4481, each with its own issue.