From 0563f008d476382ff12fd78d95c1849d17c21760 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 22 Oct 2018 09:08:11 -0400 Subject: [PATCH 1/3] Fixing CopyHelper error --- src/GitHub.Api/Installer/CopyHelper.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/GitHub.Api/Installer/CopyHelper.cs b/src/GitHub.Api/Installer/CopyHelper.cs index 22ec43579..0536426b5 100644 --- a/src/GitHub.Api/Installer/CopyHelper.cs +++ b/src/GitHub.Api/Installer/CopyHelper.cs @@ -12,6 +12,8 @@ public static class CopyHelper public static void Copy(NPath fromPath, NPath toPath) { + Logger.Trace("Error copying from " + fromPath + " to " + toPath + "."); + try { @@ -19,7 +21,7 @@ public static void Copy(NPath fromPath, NPath 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 +29,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,7 +41,7 @@ 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); } From 9223adea56996e497d2e787a380e3330cbf814d6 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 22 Oct 2018 09:30:41 -0400 Subject: [PATCH 2/3] Avoiding using the output of the zip Task because it will shorten the path names --- src/GitHub.Api/Installer/CopyHelper.cs | 1 - src/GitHub.Api/Installer/GitInstaller.cs | 12 ++++++------ src/GitHub.Api/Installer/OctorunInstaller.cs | 7 ++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/GitHub.Api/Installer/CopyHelper.cs b/src/GitHub.Api/Installer/CopyHelper.cs index 0536426b5..c489f2e19 100644 --- a/src/GitHub.Api/Installer/CopyHelper.cs +++ b/src/GitHub.Api/Installer/CopyHelper.cs @@ -49,7 +49,6 @@ public static void CopyFolder(NPath fromPath, NPath toPath) public static void CopyFolderContents(NPath fromPath, NPath toPath) { Logger.Trace("CopyFolderContents 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; From be418849906545c1557ab2976964c559340ee416 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 22 Oct 2018 09:59:25 -0400 Subject: [PATCH 3/3] Fixing log message --- src/GitHub.Api/Installer/CopyHelper.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/GitHub.Api/Installer/CopyHelper.cs b/src/GitHub.Api/Installer/CopyHelper.cs index c489f2e19..3b7f52290 100644 --- a/src/GitHub.Api/Installer/CopyHelper.cs +++ b/src/GitHub.Api/Installer/CopyHelper.cs @@ -12,11 +12,10 @@ public static class CopyHelper public static void Copy(NPath fromPath, NPath toPath) { - Logger.Trace("Error copying from " + fromPath + " to " + toPath + "."); + Logger.Trace("Copying from " + fromPath + " to " + toPath + "."); try { - CopyFolder(fromPath, toPath); } catch (Exception ex1) @@ -48,7 +47,7 @@ public static void CopyFolder(NPath fromPath, NPath 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); }