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

Commit dd041ee

Browse files
committed
Fix issues in git/octorun installer step
Skip installers if we know we have a valid git/gitlfs on startup Don't constantly copy the octorun zip if we already have it
1 parent 01020a9 commit dd041ee

File tree

3 files changed

+39
-35
lines changed

3 files changed

+39
-35
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,37 +70,43 @@ public void Run()
7070
}
7171
}
7272

73-
bool skipInstallers = false;
7473
state = SystemSettings.Get<GitInstallationState>(Constants.GitInstallationState) ?? state;
75-
var now = DateTimeOffset.Now;
76-
if (now.Date == state.GitLastCheckTime.Date && state.GitIsValid && state.GitLfsIsValid)
74+
if (state.GitIsValid && state.GitLfsIsValid)
7775
{
78-
// just check if the git/git lfs version is what we need
7976
if (firstRun)
8077
{
78+
// just check if the git/git lfs version is what we need
8179
var version = new GitVersionTask(token)
8280
.Configure(ProcessManager, state.GitExecutablePath, dontSetupGit: true)
83-
.Catch(e => true)
81+
.Catch(e =>
82+
{
83+
Logger.Error(e, "Error getting git version");
84+
return true;
85+
})
8486
.RunWithReturn(true);
8587
state.GitIsValid = version >= Constants.MinimumGitVersion;
8688
if (state.GitIsValid)
8789
{
8890
version = new GitLfsVersionTask(token)
8991
.Configure(ProcessManager, state.GitLfsExecutablePath, dontSetupGit: true)
90-
.Catch(e => true)
92+
.Catch(e =>
93+
{
94+
Logger.Error(e, "Error getting lfs version");
95+
return true;
96+
})
9197
.RunWithReturn(true);
9298
state.GitLfsIsValid = version >= Constants.MinimumGitLfsVersion;
9399
}
94100
}
95101
}
96102

97-
if (!skipInstallers)
98-
{
99-
Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager)
100-
.SetupOctorunIfNeeded();
103+
Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager)
104+
.SetupOctorunIfNeeded();
101105

106+
if (!state.GitIsValid || !state.GitLfsIsValid)
107+
{
102108
state = new GitInstaller(Environment, ProcessManager, CancellationToken, SystemSettings)
103-
{ Progress = progressReporter }
109+
{ Progress = progressReporter }
104110
.SetupGitIfNeeded();
105111
}
106112

@@ -167,7 +173,13 @@ public void SetupGit(GitInstaller.GitInstallationState state)
167173
})
168174
.RunWithReturn(true);
169175

170-
GitClient.LfsInstall().RunWithReturn(true);
176+
GitClient.LfsInstall()
177+
.Catch(e =>
178+
{
179+
Logger.Error(e, "Error running lfs install");
180+
return true;
181+
})
182+
.RunWithReturn(true);
171183

172184
if (Environment.IsWindows)
173185
{

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ public GitInstallationState VerifyGitFromSettings(GitInstallationState state)
7878
state = ValidateGitVersion(state);
7979
if (state.GitIsValid)
8080
state.GitInstallationPath = state.GitExecutablePath.Parent.Parent;
81-
else
82-
{
83-
state.GitLfsInstallationPath = NPath.Default;
84-
state.GitLfsExecutablePath = NPath.Default;
85-
}
86-
NPath gitLfsPath = ProcessManager.FindExecutableInPath(installDetails.GitLfsExecutable, true, state.GitInstallationPath);
81+
state.GitLfsExecutablePath = ProcessManager.FindExecutableInPath(installDetails.GitLfsExecutable, true, state.GitInstallationPath);
8782
state = ValidateGitLfsVersion(state);
83+
if (state.GitLfsIsValid)
84+
state.GitLfsInstallationPath = state.GitInstallationPath;
8885
return state;
8986
}
9087

src/GitHub.Api/Installer/OctorunInstaller.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,24 @@ public NPath SetupOctorunIfNeeded()
2929
NPath path = NPath.Default;
3030
var isOctorunExtracted = IsOctorunExtracted();
3131
if (isOctorunExtracted)
32-
path = installDetails.ExecutablePath;
32+
return installDetails.ExecutablePath;
33+
3334
GrabZipFromResources();
3435

35-
if (!path.IsInitialized)
36-
{
37-
var tempZipExtractPath = NPath.CreateTempDirectory("octorun_extract_archive_path");
38-
var unzipTask = new UnzipTask(taskManager.Token, installDetails.ZipFile,
39-
tempZipExtractPath, sharpZipLibHelper,
40-
fileSystem);
41-
var extractPath = unzipTask.RunWithReturn(true);
42-
if (unzipTask.Successful)
43-
path = MoveOctorun(extractPath.Combine("octorun"));
44-
tempZipExtractPath.DeleteIfExists();
45-
}
36+
var tempZipExtractPath = NPath.CreateTempDirectory("octorun_extract_archive_path");
37+
var unzipTask = new UnzipTask(taskManager.Token, installDetails.ZipFile,
38+
tempZipExtractPath, sharpZipLibHelper,
39+
fileSystem)
40+
.Catch(e => { Logger.Error(e, "Error extracting octorun"); return true; });
41+
var extractPath = unzipTask.RunWithReturn(true);
42+
if (unzipTask.Successful)
43+
path = MoveOctorun(extractPath.Combine("octorun"));
4644
return path;
4745
}
4846

4947
private NPath GrabZipFromResources()
5048
{
51-
installDetails.ZipFile.DeleteIfExists();
52-
53-
AssemblyResources.ToFile(ResourceType.Generic, "octorun.zip", installDetails.BaseZipPath, environment);
54-
55-
return installDetails.ZipFile;
49+
return AssemblyResources.ToFile(ResourceType.Generic, "octorun.zip", installDetails.BaseZipPath, environment);
5650
}
5751

5852
private NPath MoveOctorun(NPath fromPath)
@@ -61,6 +55,7 @@ private NPath MoveOctorun(NPath fromPath)
6155
toPath.DeleteIfExists();
6256
toPath.EnsureParentDirectoryExists();
6357
fromPath.Move(toPath);
58+
fromPath.Parent.Delete();
6459
return installDetails.ExecutablePath;
6560
}
6661

0 commit comments

Comments
 (0)