/// <inheritdoc /> public TRepository Clone(string repository, ObjectId commitId = null, Func <OdbBackend> backend = null) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } using (_logger.BeginScope("Cloning repository '{Repository}' from commit id '{CommitId}'.", repository, commitId)) { // Clone & load in a temp folder to extract the repository id var tempPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), UniqueId.CreateNew().ToString()); var tempRepoDescription = new RepositoryDescription(tempPath, backend); var cloned = _repositoryLoader.Clone(this, repository, tempRepoDescription, commitId); // Evict temp repository from repo provider _repositoryProvider.Evict(tempRepoDescription); // Move to target path var path = System.IO.Path.Combine(Path, cloned.Id.ToString()); Directory.Move(tempPath, path); var repositoryDescription = new RepositoryDescription(path, backend); return(ReloadRepository(repositoryDescription, cloned.CommitId)); } }