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

Commit af0e245

Browse files
Checking the hash of each zip
1 parent 133f40f commit af0e245

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ class GitInstallDetails
1111
public string GitLfsExec { get; }
1212
public NPath GitLfsExecPath { get; }
1313

14+
public const string GitExtractedMD5 = "e6cfc0c294a2312042f27f893dfc9c0a";
15+
public const string GitLfsExtractedMD5 = "ae968b69fbf42dff72311040d24a";
16+
1417
public const string WindowsGitLfsExecutableMD5 = "177bb14d0c08f665a24f0d5516c3b080";
1518
public const string MacGitLfsExecutableMD5 = "f81a1a065a26a4123193e8fd96c561ad";
1619

17-
public const string ExtractedMD5 = "65fd0575d3b47d8207b9e19d02faca4f";
1820
public const string FileListMD5 = "a152a216b2e76f6c127053251187a278";
1921

2022
private const string PackageVersion = "f02737a78695063deace08e96d5042710d3e32db";
@@ -108,22 +110,14 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
108110

109111
var gitExtractPath = tempZipPath.Combine("git").CreateDirectory();
110112
var gitLfsExtractPath = tempZipPath.Combine("git-lfs").CreateDirectory();
111-
112-
new UnzipTask(cancellationToken, gitArchivePath, gitExtractPath, sharpZipLibHelper)
113-
.Then(new UnzipTask(cancellationToken, gitLfsArchivePath, gitLfsExtractPath, sharpZipLibHelper))
113+
114+
new UnzipTask(cancellationToken, gitArchivePath, gitExtractPath, sharpZipLibHelper, environment.FileSystem, GitInstallDetails.GitExtractedMD5)
115+
.Then(new UnzipTask(cancellationToken, gitLfsArchivePath, gitLfsExtractPath, sharpZipLibHelper, environment.FileSystem, GitInstallDetails.GitLfsExtractedMD5))
114116
.Then(() => {
115117
var targetGitLfsExecPath = installDetails.GetGitLfsExecPath(gitExtractPath);
116118
var extractGitLfsExePath = gitLfsExtractPath.Combine(installDetails.GitLfsExec);
117119
extractGitLfsExePath.Move(targetGitLfsExecPath);
118120

119-
var extractedMD5 = environment.FileSystem.CalculateFolderMD5(gitExtractPath);
120-
if (!extractedMD5.Equals(GitInstallDetails.ExtractedMD5, StringComparison.InvariantCultureIgnoreCase))
121-
{
122-
Logger.Warning("MD5 {0} does not match expected {1}", extractedMD5, GitInstallDetails.ExtractedMD5);
123-
Logger.Warning("Failed PortableGitInstallTask");
124-
throw new Exception();
125-
}
126-
127121
Logger.Trace("Moving tempDirectory:\"{0}\" to extractTarget:\"{1}\"", gitExtractPath,
128122
installDetails.GitInstallPath);
129123

src/tests/IntegrationTests/UnzipTaskTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ namespace IntegrationTests
1313
[TestFixture]
1414
class UnzipTaskTests : BaseTaskManagerTest
1515
{
16-
private const string GitZipMD5 = "e6cfc0c294a2312042f27f893dfc9c0a";
17-
1816
[Test]
1917
public void TaskSucceeds()
2018
{
@@ -30,7 +28,7 @@ public void TaskSucceeds()
3028

3129
var zipProgress = 0;
3230
Logger.Trace("Pct Complete {0}%", zipProgress);
33-
var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath, Environment.FileSystem, GitZipMD5,
31+
var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath, Environment.FileSystem, GitInstallDetails.GitExtractedMD5,
3432
new Progress<float>(zipFileProgress => {
3533
var zipFileProgressInteger = (int) (zipFileProgress * 100);
3634
if (zipProgress != zipFileProgressInteger)

0 commit comments

Comments
 (0)