Function workerlib::try_mirror
source · pub async fn try_mirror(
lorry_details: &LorrySpec,
lorry_name: &str,
downstream_url: &Url,
workspace: &Workspace,
arguments: &Arguments
) -> Result<MirrorStatus, Error>
Expand description
Attempt to mirror a repository from an upstream host into the configured downstream server. NOTE: The only supported downstream configuration is currently Gitlab.
Rough outline of the order of operations is:
-
Attempt to fetch repository data from the downstream into the working directory of the local mirror.
-
Fetch the upstream repository on top of the working directory of the local mirror applying new updates.
-
Push the local mirror back into the downstream updating it with new refs.
Fetching the downstream repository initially ensures that Lorry can work in a stateless environment and will consider the downstream mirror the source of truth.
This workflow applies to both LFS and normal Git mirrors. In the case of LFS the raw files are also downloaded into the working directory prior to running download operations.
In the event that the downstream repository becomes corrupted in someway the procedure is to delete and reinitialize an empty repository in which case the upstream mirror will be re-imported from scratch.
TODO: This code can be factored out better