Skip to main content

Crate git_lfs_store

Crate git_lfs_store 

Source
Expand description

Content-addressable on-disk store for Git LFS objects.

Git LFS keeps large files outside git’s object database, leaving small pointer blobs committed to git in their place. This crate owns the local half of that split: where the actual file bytes live on disk, how they get there, and how they’re served back out.

Objects live under <lfs_dir>/objects/aa/bb/aabbcc… where the hex string is the SHA-256 of the content, sharded by the first two bytes (see docs/spec.md). Writes go through a tempfile in <lfs_dir>/tmp/ and are atomically renamed into place once their hash is known.

Two insert paths cover the two callers: Store::insert hashes bytes as they’re written (the clean-filter path: bytes in, OID out), and Store::insert_verified checks the resulting hash against a caller-supplied expected OID (the download path: the server names the OID, we confirm what arrived).

In-progress downloads stage as .part files at Store::incomplete_path and rename into place via Store::commit_partial, so an interrupted transfer resumes with a Range: request rather than restarting. Alternate object stores attached via Store::with_references are hardlinked or copied into the primary on a miss (the LFS analogue of git clone --shared). File and directory modes follow core.sharedRepository, see Store::with_shared_repository.

use git_lfs_store::Store;

let store = Store::new(&lfs_dir);
let (oid, size) = store.insert(&mut &b"hello world"[..]).unwrap();
assert!(store.contains(oid));
assert_eq!(size, 11);

Structs§

Store
A local LFS object store rooted at <lfs_dir> (typically .git/lfs).

Enums§

StoreError
Things that can go wrong while inserting an object.