Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

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

Implementations§

Source§

impl Store

Source

pub fn new(lfs_dir: impl Into<PathBuf>) -> Self

Create a store rooted at the given LFS directory. The directory is not created eagerly; subdirectories are created on demand as objects land.

Source

pub fn root(&self) -> &Path

Root LFS directory.

Source

pub fn tmp_dir(&self) -> PathBuf

Directory holding temp files for in-flight inserts.

Source

pub fn object_path(&self, oid: Oid) -> PathBuf

Where the object with this OID lives on disk.

For Oid::EMPTY this returns the platform null device, mirroring upstream’s behavior so callers can open an empty object without special-casing.

Source

pub fn contains(&self, oid: Oid) -> bool

true if this object is present locally as a regular file. The empty OID is always considered present.

Source

pub fn contains_with_size(&self, oid: Oid, size: u64) -> bool

true if the object is present and its on-disk size matches size. Used to detect partial/corrupted local copies.

Source

pub fn each_object(&self) -> Result<Vec<(Oid, u64)>>

Walk every object file in the store, yielding (oid, size_on_disk).

Traverses the sharded objects/<aa>/<bb>/<oid> layout. Filenames that don’t parse as 64-char SHA-256 hex are silently skipped, as are unexpected directories. The store directory not existing is not an error — the result is just empty.

Used by git lfs prune and (eventually) fsck --orphaned.

Source

pub fn open(&self, oid: Oid) -> Result<File>

Open an object for reading. Errors with io::ErrorKind::NotFound if the object isn’t in the store.

Source

pub fn insert(&self, src: &mut impl Read) -> Result<(Oid, u64), StoreError>

Stream src into the store, computing SHA-256 as we go. Returns the resulting OID and byte count.

This is the clean-filter path: we don’t know the OID until after the content is hashed.

Source

pub fn insert_verified( &self, expected: Oid, src: &mut impl Read, ) -> Result<u64, StoreError>

Stream src into the store, requiring the resulting hash to equal expected. On mismatch, returns StoreError::HashMismatch and the temp file is dropped without being committed.

This is the download path: we know the OID upfront and must verify what the server sent.

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.