Skip to main content

Crate twilight_cas

Crate twilight_cas 

Source
Expand description

uv-style global content-addressable store (CAS) engine.

Blobs live under <cas_root>/sha1/<xx>/<full_sha1_hash> and are linked into target directories through a strategy cascade: hardlink → NTFS junction (Windows) → symlink → plain copy, so deduplication never breaks downstream consumers (e.g. game launches). Fully generic: no game, launcher or Minecraft terms anywhere in the public API.

Structs§

CasStats
Live CAS stats: number of stored blobs and their total size in bytes.
DedupeReport
Outcome of deduplicate_dirs: scanned files, replaced files and approximate bytes the duplicates consumed before linking.
GcReport
Outcome of cas_garbage_collect_dirs.
IngestResult
Result of ingest_file: the blob hash and whether the blob already existed in the CAS.

Enums§

CasError
LinkKind
Which strategy materialized one link (reported to callers and logs).

Functions§

blob_path
cas_garbage_collect_dirs
Removes CAS blobs that no active directory references. The referenced set is recomputed by hashing files, so deletion is safe for linked consumers too.
cas_stats
Scans <cas_root>/sha1 and returns the blob count + total size.
deduplicate_dirs
Deduplicates files across dirs: ingests every candidate into the CAS, then replaces the duplicate copies with links (temp-link + rename; a failure never loses a file). A None extension list matches all files.
ingest_file
Streams src into the CAS, hashing while reading; atomic rename into place when the blob is new. Reuses an existing blob if another ingest won the race, so concurrent ingests converge instead of failing.
link_or_copy
Links (or copies) cas_blob to dest. dest must not exist yet. The cascade is hardlink → NTFS junction (Windows) → symlink → copy, so the worst case is always a real copy. Returns the winning strategy so callers and diagnostics can report the true cost.