pub struct GitCache { /* private fields */ }Implementations§
Source§impl GitCache
impl GitCache
pub fn new( cfg: GitConfig, metrics: Arc<Metrics>, index: Option<Arc<CacheIndex>>, ) -> Self
Sourcepub async fn evict(&self, name: &str, cache_dir: &Path) -> Result<()>
pub async fn evict(&self, name: &str, cache_dir: &Path) -> Result<()>
Evict a mirror: rename it out of the way, then remove it. Serialized against
clone/fetch for the same repo via its slot lock, so it never races the work
that populates the mirror. The rename is atomic and fast; the (possibly slow)
removal runs after the lock is released. ensure_fresh keys off
HEAD.exists(), so the next request for an evicted repo transparently
re-clones. An upload-pack already streaming from the old directory keeps
its open file descriptors and drains cleanly (POSIX unlink semantics).
Sourcepub async fn ensure_fresh(
&self,
repo: &RepoRef,
want_fetch: bool,
) -> Result<CacheOutcome>
pub async fn ensure_fresh( &self, repo: &RepoRef, want_fetch: bool, ) -> Result<CacheOutcome>
Ensure the mirror exists and (when want_fetch) is fresh. Concurrent
callers for the same repo are serialized; the first does the work, the
rest see it already fresh.
Sourcepub async fn advertise_refs(
&self,
repo: &RepoRef,
git_protocol: Option<&str>,
) -> Result<Bytes>
pub async fn advertise_refs( &self, repo: &RepoRef, git_protocol: Option<&str>, ) -> Result<Bytes>
git upload-pack --advertise-refs, wrapped with the smart-HTTP service
header - i.e. the GET .../info/refs?service=git-upload-pack body.
Sourcepub async fn upload_pack_rpc(
&self,
repo: &RepoRef,
git_protocol: Option<&str>,
body: Bytes,
) -> Result<ReaderStream<TimedReader<ChildStdout>>>
pub async fn upload_pack_rpc( &self, repo: &RepoRef, git_protocol: Option<&str>, body: Bytes, ) -> Result<ReaderStream<TimedReader<ChildStdout>>>
Stream git upload-pack --stateless-rpc - i.e. the
POST .../git-upload-pack response (the packfile). The request body
(the client’s want/have negotiation) is small and buffered; the response
can be gigabytes, so it is streamed straight from the child’s stdout.