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

Commit 117a44d

Browse files
Removing download result object
1 parent ad927a6 commit 117a44d

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

src/GitHub.Api/Tasks/DownloadTask.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,6 @@ public static bool Copy(Stream source, Stream destination, int chunkSize, long t
7575
}
7676
}
7777

78-
public class DownloadResult
79-
{
80-
public bool Success { get; set; }
81-
82-
public string Url { get; set; }
83-
84-
public string Destination { get; set; }
85-
86-
public string MD5Sum { get; set; }
87-
}
88-
8978
public static class WebRequestExtensions
9079
{
9180
public static WebResponse GetResponseWithoutException(this WebRequest request)
@@ -101,7 +90,7 @@ public static WebResponse GetResponseWithoutException(this WebRequest request)
10190
}
10291
}
10392

104-
class DownloadTask : TaskBase<DownloadResult>
93+
class DownloadTask : TaskBase
10594
{
10695
private IFileSystem fileSystem;
10796
private long bytes;
@@ -119,9 +108,9 @@ public DownloadTask(CancellationToken token, IFileSystem fileSystem, string url,
119108
Name = "DownloadTask";
120109
}
121110

122-
protected override DownloadResult RunWithReturn(bool success)
111+
protected override void Run(bool success)
123112
{
124-
base.RunWithReturn(success);
113+
base.Run(success);
125114

126115
RaiseOnStart();
127116

@@ -144,10 +133,8 @@ protected override DownloadResult RunWithReturn(bool success)
144133
}
145134
finally
146135
{
147-
RaiseOnEnd(downloadResult);
136+
RaiseOnEnd();
148137
}
149-
150-
return downloadResult;
151138
}
152139

153140
protected virtual void UpdateProgress(float progress)

src/tests/IntegrationTests/Download/DownloadTaskTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ public async Task TestDownloadTask()
2626
var downloadHalfPath = TestBasePath.Combine("5MB-split.zip");
2727

2828
var downloadTask = new DownloadTask(CancellationToken.None, fileSystem, TestDownload, downloadPath);
29-
var downloadResult = await downloadTask.StartAwait();
29+
await downloadTask.StartAwait();
3030

3131
var downloadPathBytes = fileSystem.ReadAllBytes(downloadPath);
3232
Logger.Trace("File size {0} bytes", downloadPathBytes.Length);
3333

34-
downloadResult.MD5Sum.Should().Be(TestDownloadMD5.ToUpperInvariant());
34+
var md5Sum = fileSystem.CalculateMD5(downloadPath);
35+
md5Sum.Should().Be(TestDownloadMD5.ToUpperInvariant());
3536

3637
var random = new Random();
3738
var takeCount = random.Next(downloadPathBytes.Length);
@@ -42,12 +43,13 @@ public async Task TestDownloadTask()
4243
fileSystem.WriteAllBytes(downloadHalfPath, cutDownloadPathBytes);
4344

4445
downloadTask = new DownloadTask(CancellationToken.None, fileSystem, TestDownload, downloadHalfPath);
45-
downloadResult = await downloadTask.StartAwait();
46+
await downloadTask.StartAwait();
4647

4748
var downloadHalfPathBytes = fileSystem.ReadAllBytes(downloadHalfPath);
4849
Logger.Trace("File size {0} Bytes", downloadHalfPathBytes.Length);
4950

50-
downloadResult.MD5Sum.Should().Be(TestDownloadMD5.ToUpperInvariant());
51+
md5Sum = fileSystem.CalculateMD5(downloadPath);
52+
md5Sum.Should().Be(TestDownloadMD5.ToUpperInvariant());
5153
}
5254

5355
[Test]

0 commit comments

Comments
 (0)