diff --git a/src/GitHub.Api/Installer/CopyHelper.cs b/src/GitHub.Api/Installer/CopyHelper.cs index 22ec43579..3b7f52290 100644 --- a/src/GitHub.Api/Installer/CopyHelper.cs +++ b/src/GitHub.Api/Installer/CopyHelper.cs @@ -12,14 +12,15 @@ public static class CopyHelper public static void Copy(NPath fromPath, NPath toPath) { + Logger.Trace("Copying from " + fromPath + " to " + toPath + "."); + try { - CopyFolder(fromPath, toPath); } catch (Exception ex1) { - Logger.Warning(ex1, "Error copying from " + fromPath + " to " + toPath + ". Attempting to copy contents."); + Logger.Warning(ex1, "Error copying."); try { @@ -27,7 +28,7 @@ public static void Copy(NPath fromPath, NPath toPath) } catch (Exception ex2) { - Logger.Error(ex2, "Error copying from " + fromPath + " to " + toPath + "."); + Logger.Error(ex1, "Error copying contents."); throw; } } @@ -39,15 +40,14 @@ public static void Copy(NPath fromPath, NPath toPath) public static void CopyFolder(NPath fromPath, NPath toPath) { Logger.Trace("CopyFolder fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString()); - + toPath.DeleteIfExists(); toPath.EnsureParentDirectoryExists(); fromPath.Move(toPath); } public static void CopyFolderContents(NPath fromPath, NPath toPath) { - Logger.Trace("CopyFolderContents fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString()); - + Logger.Trace("CopyFolder Contents fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString()); toPath.DeleteContents(); fromPath.MoveFiles(toPath, true); } diff --git a/src/GitHub.Api/Installer/GitInstaller.cs b/src/GitHub.Api/Installer/GitInstaller.cs index 67b502a94..2c38cff89 100644 --- a/src/GitHub.Api/Installer/GitInstaller.cs +++ b/src/GitHub.Api/Installer/GitInstaller.cs @@ -301,13 +301,13 @@ private GitInstallationState ExtractGit(GitInstallationState state) return true; }); unzipTask.Progress(p => Progress.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Message)); - var source = unzipTask.RunSynchronously(); + unzipTask.RunSynchronously(); var target = state.GitInstallationPath; if (unzipTask.Successful) { - Logger.Trace("Moving Git source:{0} target:{1}", source.ToString(), target.ToString()); + Logger.Trace("Moving Git source:{0} target:{1}", gitExtractPath.ToString(), target.ToString()); - CopyHelper.Copy(source, target); + CopyHelper.Copy(gitExtractPath, target); state.GitIsValid = true; @@ -327,13 +327,13 @@ private GitInstallationState ExtractGit(GitInstallationState state) return true; }); unzipTask.Progress(p => Progress.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Message)); - var source = unzipTask.RunSynchronously(); + unzipTask.RunSynchronously(); var target = state.GitLfsInstallationPath; if (unzipTask.Successful) { - Logger.Trace("Moving GitLFS source:{0} target:{1}", source.ToString(), target.ToString()); + Logger.Trace("Moving GitLFS source:{0} target:{1}", gitLfsExtractPath.ToString(), target.ToString()); - CopyHelper.Copy(source, target); + CopyHelper.Copy(gitLfsExtractPath, target); state.GitLfsIsValid = true; } diff --git a/src/GitHub.Api/Installer/OctorunInstaller.cs b/src/GitHub.Api/Installer/OctorunInstaller.cs index 0aa655d93..6b989677b 100644 --- a/src/GitHub.Api/Installer/OctorunInstaller.cs +++ b/src/GitHub.Api/Installer/OctorunInstaller.cs @@ -33,12 +33,13 @@ public NPath SetupOctorunIfNeeded() GrabZipFromResources(); - var tempZipExtractPath = NPath.CreateTempDirectory("octorun_extract_archive_path"); + var extractPath = NPath.CreateTempDirectory("octorun_extract_archive_path"); var unzipTask = new UnzipTask(taskManager.Token, installDetails.ZipFile, - tempZipExtractPath, sharpZipLibHelper, + extractPath, sharpZipLibHelper, fileSystem) .Catch(e => { Logger.Error(e, "Error extracting octorun"); return true; }); - var extractPath = unzipTask.RunSynchronously(); + unzipTask.RunSynchronously(); + if (unzipTask.Successful) path = MoveOctorun(extractPath.Combine("octorun")); return path;