예제 #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.RunSynchronously();

            if (unzipTask.Successful)
            {
                path = MoveOctorun(extractPath.Combine("octorun"));
            }
            return(path);
        }
예제 #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));
                unzipTask.RunSynchronously();
                var target = state.GitInstallationPath;
                if (unzipTask.Successful)
                {
                    Logger.Trace("Moving Git source:{0} target:{1}", gitExtractPath.ToString(), target.ToString());

                    CopyHelper.Copy(gitExtractPath, 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));
                unzipTask.RunSynchronously();
                var target = state.GitLfsInstallationPath;
                if (unzipTask.Successful)
                {
                    Logger.Trace("Moving GitLFS source:{0} target:{1}", gitLfsExtractPath.ToString(), target.ToString());

                    CopyHelper.Copy(gitLfsExtractPath, target);

                    state.GitLfsIsValid = true;
                }
            }

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