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

Changing how zip extracted resources are moved to their destination #925

Merged
merged 10 commits into from
Oct 9, 2018
Merged
25 changes: 15 additions & 10 deletions src/GitHub.Api/Installer/GitInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,18 @@ private GitInstallationState ExtractGit(GitInstallationState state)
return true;
});
unzipTask.Progress(p => Progress.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Message));
var path = unzipTask.RunSynchronously();
var source = unzipTask.RunSynchronously();
var target = state.GitInstallationPath;
if (unzipTask.Successful)
{
var source = path;
target.DeleteIfExists();
target.EnsureParentDirectoryExists();
source.Move(target);
Logger.Trace("Moving Git source:{0} target:{1}", source.ToString(), target.ToString());

target.DeleteContents();
source.MoveFiles(target, true);
source.Parent.Delete();

state.GitIsValid = true;

state.IsCustomGitPath = state.GitExecutablePath != installDetails.GitExecutablePath;
}
}
Expand All @@ -326,14 +329,16 @@ private GitInstallationState ExtractGit(GitInstallationState state)
return true;
});
unzipTask.Progress(p => Progress.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Message));
var path = unzipTask.RunSynchronously();
var source = unzipTask.RunSynchronously();
var target = state.GitLfsInstallationPath;
if (unzipTask.Successful)
{
var source = path;
target.DeleteIfExists();
target.EnsureParentDirectoryExists();
source.Move(target);
Logger.Trace("Moving GitLFS source:{0} target:{1}", source.ToString(), target.ToString());

target.DeleteContents();
source.MoveFiles(target, true);
source.Parent.Delete();

state.GitLfsIsValid = true;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/GitHub.Api/Installer/OctorunInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ private NPath GrabZipFromResources()
private NPath MoveOctorun(NPath fromPath)
{
var toPath = installDetails.InstallationPath;
toPath.DeleteIfExists();
toPath.EnsureParentDirectoryExists();
fromPath.Move(toPath);

Logger.Trace("MoveOctorun fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString());

toPath.DeleteContents();
fromPath.MoveFiles(toPath, true);
fromPath.Parent.Delete();

return installDetails.ExecutablePath;
}

Expand Down