ExStorageService.Storage.CAS (ex_storage_service v0.6.4)

Copy Markdown View Source

Global content-addressable blob store under the reserved cas/ root.

Layout: {data_root}/cas/objects/sha256/{first_two_hex}/{rest}.

Blobs are immutable and shared across all buckets, keys, and versions. Commit is a synced atomic rename from a tmp file on the same filesystem. All functions are plain path/filesystem operations executed in the caller's process — this module deliberately has no process.

cas is a reserved name: BucketValidator rejects it as a bucket name and ContentGC skips it when scanning the legacy bucket-local layout.

Summary

Functions

Atomically moves tmp_path into the CAS. If the blob already exists (dedup hit), the tmp file is discarded and the existing blob is kept.

Returns a unique path inside cas/tmp/uploads/, creating the directory. The tmp dir shares a filesystem with cas/objects/, so commit_blob/2 can rename atomically.

Re-hashes the blob file and compares against its content hash.

Functions

blob_path(content_hash)

blob_root()

commit_blob(tmp_path, content_hash)

Atomically moves tmp_path into the CAS. If the blob already exists (dedup hit), the tmp file is discarded and the existing blob is kept.

data_root()

has_blob?(content_hash)

reserved_root()

tmp_root()

tmp_upload_path()

Returns a unique path inside cas/tmp/uploads/, creating the directory. The tmp dir shares a filesystem with cas/objects/, so commit_blob/2 can rename atomically.

verify_blob(content_hash)

Re-hashes the blob file and compares against its content hash.