Skip to main content

Module repo

Module repo 

Source
Expand description

Request-path -> (upstream URL, on-disk cache dir) resolution, hardened against path traversal.

Structs§

RepoRef
A resolved repository: where to fetch it from and where it is cached.

Constants§

EVICTING_SUFFIX
Reserved suffix for the trash directory a mirror is renamed to during eviction before its (possibly slow) removal (see git::GitCache::evict). Reserved for the same reason as INCOMING_SUFFIX: a client path must never alias a mirror mid-eviction.
INCOMING_SUFFIX
Reserved suffix for the staging directory a mirror is cloned into before its atomic rename into place (see git::clone_mirror). resolve rejects any client path containing it, so a request can never resolve onto another repo’s in-flight clone directory.
LFS_OBJECTS_DIR
Reserved top-level directory under the cache root holding cached git-LFS objects (content-addressed by oid, shared across repos - see lfs_object_path). Reserved like the suffixes above so a client repo path can never resolve into the LFS store.

Functions§

lfs_batch_repo
Repo name for the LFS batch endpoint (<repo>/info/lfs/objects/batch), or None if the path is not a batch request.
lfs_object_from_path
Split an LFS object path (<repo>/info/lfs/objects/<oid>) into (repo, oid). Any query string must be stripped by the caller. None if the path is not an object request or the oid is malformed.
lfs_object_key
Cache key of an LFS object: its path relative to the cache root, /-joined so it matches the keys the eviction index uses for mirrors. Content-addressed and shared across all repos (the oid is the content hash), sharded by the first two hex chars so no single directory holds every object. Caller must pass a valid_lfs_oid.
lfs_object_path
On-disk path of a cached LFS object (cache_root joined with lfs_object_key).
repo_name_from_path
Strip a smart-HTTP endpoint suffix (/info/refs, /git-upload-pack) from a request path and return the repo name. None if the suffix isn’t present.
resolve
Validate a repo path (no traversal / absolute / NUL) and resolve it against the upstream base and cache root.
valid_lfs_oid
An LFS oid is the lowercase-hex sha256 of the object’s content: 64 hex digits. Validated before use as both a filesystem path component and the cache key.