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

Commit 5d0a425

Browse files
committed
We can't do an md5 folder check after unzipping, it's not going to be deterministic
OSes will write stuff to disk which will change the md5 sum
1 parent e554673 commit 5d0a425

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private FuncTask<NPath> ExtractPortableGit(GitInstallationState state)
146146
if (!state.GitIsValid)
147147
{
148148
ITask<NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitZipPath, gitExtractPath, sharpZipLibHelper,
149-
environment.FileSystem, GitInstallDetails.GitExtractedMD5);
149+
environment.FileSystem);
150150
unzipTask.Progress(p => installationTask.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Name));
151151

152152
unzipTask = unzipTask.Then((s, path) =>
@@ -169,7 +169,7 @@ private FuncTask<NPath> ExtractPortableGit(GitInstallationState state)
169169
if (!state.GitLfsIsValid)
170170
{
171171
ITask<NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitLfsZipPath, gitLfsExtractPath, sharpZipLibHelper,
172-
environment.FileSystem, GitInstallDetails.GitLfsExtractedMD5);
172+
environment.FileSystem);
173173
unzipTask.Progress(p => installationTask.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Name));
174174

175175
unzipTask = unzipTask.Then((s, path) =>

src/GitHub.Api/Installer/OctorunInstaller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public ITask<NPath> SetupOctorunIfNeeded()
4545
var tempZipExtractPath = NPath.CreateTempDirectory("octorun_extract_archive_path");
4646
var unzipTask = new UnzipTask(taskManager.Token, installDetails.ZipFile,
4747
tempZipExtractPath, sharpZipLibHelper,
48-
fileSystem, OctorunInstallDetails.ExtractedMD5)
48+
fileSystem)
4949
.Then((success, p) => MoveOctorun(p));
5050
t.Then(unzipTask);
5151
}

src/GitHub.Api/Installer/UnzipTask.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ class UnzipTask : TaskBase<NPath>
1212
private readonly string expectedMD5;
1313

1414
public UnzipTask(CancellationToken token, NPath archiveFilePath, NPath extractedPath,
15-
IZipHelper zipHelper, IFileSystem fileSystem, string expectedMD5)
15+
IZipHelper zipHelper, IFileSystem fileSystem)
1616
: base(token)
1717
{
1818
this.archiveFilePath = archiveFilePath;
1919
this.extractedPath = extractedPath;
2020
this.zipHelper = zipHelper;
2121
this.fileSystem = fileSystem;
22-
this.expectedMD5 = expectedMD5;
2322
Name = $"Unzip {archiveFilePath.FileName}";
2423
}
2524

@@ -71,22 +70,14 @@ protected virtual NPath RunUnzip(bool success)
7170
UpdateProgress(value, total);
7271
return !Token.IsCancellationRequested;
7372
});
74-
/*
75-
if (expectedMD5 != null)
76-
{
77-
var calculatedMD5 = fileSystem.CalculateFolderMD5(extractedPath);
78-
success = calculatedMD5.Equals(expectedMD5, StringComparison.InvariantCultureIgnoreCase);
79-
*/
80-
if (!success)
81-
{
82-
extractedPath.DeleteIfExists();
8373

84-
//var message = $"Extracted MD5: {calculatedMD5} Does not match expected: {expectedMD5}";
85-
var message = $"Failed to extract {archiveFilePath} to {extractedPath}";
74+
if (!success)
75+
{
76+
extractedPath.DeleteIfExists();
8677

87-
exception = new UnzipException(message);
88-
}
89-
// }
78+
var message = $"Failed to extract {archiveFilePath} to {extractedPath}";
79+
exception = new UnzipException(message);
80+
}
9081
}
9182
catch (Exception ex)
9283
{

src/tests/IntegrationTests/UnzipTaskTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public async Task UnzipWorks()
2727

2828
var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath,
2929
ZipHelper.Instance,
30-
Environment.FileSystem, GitInstaller.GitInstallDetails.GitLfsExtractedMD5)
30+
Environment.FileSystem)
3131
.Progress(p =>
3232
{
3333
});
@@ -51,7 +51,7 @@ public void FailsWhenMD5Incorrect()
5151
var extractedPath = TestBasePath.Combine("gitlfs_zip_extracted").CreateDirectory();
5252

5353
var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath,
54-
ZipHelper.Instance, Environment.FileSystem, "AABBCCDD");
54+
ZipHelper.Instance, Environment.FileSystem);
5555

5656
Assert.Throws<UnzipException>(async () => await unzipTask.StartAwait());
5757

0 commit comments

Comments
 (0)