Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Fixing GitHub for Unity initialization #945

Merged
merged 4 commits into from
Oct 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/GitHub.Api/Installer/CopyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ 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
{
CopyFolderContents(fromPath, toPath);
}
catch (Exception ex2)
{
Logger.Error(ex2, "Error copying from " + fromPath + " to " + toPath + ".");
Logger.Error(ex1, "Error copying contents.");
throw;
}
}
Expand All @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/GitHub.Api/Installer/GitInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/GitHub.Api/Installer/OctorunInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down