/// <inheritdoc/> public async Task CloneRepository( string cloneUrl, string repositoryName, string repositoryPath, object progress = null) { Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl)); Guard.ArgumentNotEmptyString(repositoryName, nameof(repositoryName)); Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath)); string path = Path.Combine(repositoryPath, repositoryName); // Switch to a thread pool thread for IO then back to the main thread to call // vsGitServices.Clone() as this must be called on the main thread. await ThreadingHelper.SwitchToPoolThreadAsync(); operatingSystem.Directory.CreateDirectory(path); await ThreadingHelper.SwitchToMainThreadAsync(); try { await vsGitServices.Clone(cloneUrl, path, true, progress); await usageTracker.IncrementCloneCount(); } catch (Exception ex) { log.Error(ex, "Could not clone {CloneUrl} to {Path}", cloneUrl, path); throw; } }
IObservable <Unit> OnCloneRepository(object state) { return(Observable.Start(() => { var repository = SelectedRepository; Debug.Assert(repository != null, "Should not be able to attempt to clone a repo when it's null"); if (repository == null) { notificationService.ShowError(Resources.RepositoryCloneFailedNoSelectedRepo); return Observable.Return(Unit.Default); } // The following is a noop if the directory already exists. operatingSystem.Directory.CreateDirectory(BaseRepositoryPath); return cloneService.CloneRepository(repository.CloneUrl, repository.Name, BaseRepositoryPath) .ContinueAfter(() => { usageTracker.IncrementCloneCount(); return Observable.Return(Unit.Default); }); }) .SelectMany(_ => _) .Catch <Unit, Exception>(e => { var repository = SelectedRepository; Debug.Assert(repository != null, "Should not be able to attempt to clone a repo when it's null"); notificationService.ShowError(e.GetUserFriendlyErrorMessage(ErrorType.ClonedFailed, repository.Name)); return Observable.Return(Unit.Default); })); }
public Task IncrementCloneCount() => inner.IncrementCloneCount();