Exemplo n.º 1
0
        private void ExtractPortableGit(ActionTask <NPath> onSuccess, ITask onFailure)
        {
            ITask downloadFilesTask = null;

            if ((gitArchiveFilePath == null) || (gitLfsArchivePath == null))
            {
                downloadFilesTask = CreateDownloadTask();
            }

            var tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths");
            var gitExtractPath     = tempZipExtractPath.Combine("git").CreateDirectory();
            var gitLfsExtractPath  = tempZipExtractPath.Combine("git-lfs").CreateDirectory();

            var resultTask = new UnzipTask(cancellationToken, gitArchiveFilePath, gitExtractPath, sharpZipLibHelper, environment.FileSystem, GitInstallDetails.GitExtractedMD5)
                             .Then(new UnzipTask(cancellationToken, gitLfsArchivePath, gitLfsExtractPath, sharpZipLibHelper, environment.FileSystem, GitInstallDetails.GitLfsExtractedMD5))
                             .Then(s => MoveGitAndLfs(gitExtractPath, gitLfsExtractPath, tempZipExtractPath));

            resultTask.Then(onFailure, TaskRunOptions.OnFailure);
            resultTask.Then(onSuccess, TaskRunOptions.OnSuccess);

            if (downloadFilesTask != null)
            {
                resultTask = downloadFilesTask.Then(resultTask);
            }

            resultTask.Start();
        }