Exemplo n.º 1
0
        public NPath SetupOctorunIfNeeded()
        {
            NPath path = NPath.Default;
            var   isOctorunExtracted = IsOctorunExtracted();

            if (isOctorunExtracted)
            {
                return(installDetails.ExecutablePath);
            }

            GrabZipFromResources();

            var tempZipExtractPath = NPath.CreateTempDirectory("octorun_extract_archive_path");
            var unzipTask          = new UnzipTask(taskManager.Token, installDetails.ZipFile,
                                                   tempZipExtractPath, sharpZipLibHelper,
                                                   fileSystem)
                                     .Catch(e => { Logger.Error(e, "Error extracting octorun"); return(true); });
            var extractPath = unzipTask.RunWithReturn(true);

            if (unzipTask.Successful)
            {
                path = MoveOctorun(extractPath.Combine("octorun"));
            }
            return(path);
        }
Exemplo n.º 2
0
        private GitInstallationState ExtractGit(GitInstallationState state)
        {
            var tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths");

            if (state.GitZipExists && !state.GitIsValid)
            {
                var gitExtractPath = tempZipExtractPath.Combine("git").CreateDirectory();
                var unzipTask      = new UnzipTask(cancellationToken, installDetails.GitZipPath,
                                                   gitExtractPath, sharpZipLibHelper,
                                                   environment.FileSystem)
                                     .Catch(e =>
                {
                    LogHelper.Trace(e, "Failed to unzip " + installDetails.GitZipPath);
                    return(true);
                });
                unzipTask.Progress(p => Progress.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Message));
                var path   = unzipTask.RunWithReturn(true);
                var target = state.GitInstallationPath;
                if (unzipTask.Successful)
                {
                    var source = path;
                    target.DeleteIfExists();
                    target.EnsureParentDirectoryExists();
                    source.Move(target);
                    state.GitIsValid      = true;
                    state.IsCustomGitPath = state.GitExecutablePath != installDetails.GitExecutablePath;
                }
            }

            if (state.GitLfsZipExists && !state.GitLfsIsValid)
            {
                var gitLfsExtractPath = tempZipExtractPath.Combine("git-lfs").CreateDirectory();
                var unzipTask         = new UnzipTask(cancellationToken, installDetails.GitLfsZipPath,
                                                      gitLfsExtractPath, sharpZipLibHelper,
                                                      environment.FileSystem)
                                        .Catch(e =>
                {
                    LogHelper.Trace(e, "Failed to unzip " + installDetails.GitLfsZipPath);
                    return(true);
                });
                unzipTask.Progress(p => Progress.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Message));
                var path   = unzipTask.RunWithReturn(true);
                var target = state.GitLfsInstallationPath;
                if (unzipTask.Successful)
                {
                    var source = path;
                    target.DeleteIfExists();
                    target.EnsureParentDirectoryExists();
                    source.Move(target);
                    state.GitLfsIsValid = true;
                }
            }

            tempZipExtractPath.DeleteIfExists();
            return(state);
        }