diff --git a/StabilityMatrix/Services/DownloadService.cs b/StabilityMatrix/Services/DownloadService.cs index 7471771d..cf29d763 100644 --- a/StabilityMatrix/Services/DownloadService.cs +++ b/StabilityMatrix/Services/DownloadService.cs @@ -13,6 +13,7 @@ public class DownloadService : IDownloadService { private readonly ILogger logger; private readonly IHttpClientFactory httpClientFactory; + private const int BufferSize = ushort.MaxValue; public DownloadService(ILogger logger, IHttpClientFactory httpClientFactory) { @@ -20,7 +21,7 @@ public class DownloadService : IDownloadService this.httpClientFactory = httpClientFactory; } - public async Task DownloadToFileAsync(string downloadUrl, string downloadLocation, int bufferSize = ushort.MaxValue, + public async Task DownloadToFileAsync(string downloadUrl, string downloadLocation, IProgress? progress = null, string? httpClientName = null) { using var client = string.IsNullOrWhiteSpace(httpClientName) @@ -51,7 +52,7 @@ public class DownloadService : IDownloadService await using var stream = await response.Content.ReadAsStreamAsync(); var totalBytesRead = 0L; - var buffer = new byte[bufferSize]; + var buffer = new byte[BufferSize]; while (true) { var bytesRead = await stream.ReadAsync(buffer); diff --git a/StabilityMatrix/Services/IDownloadService.cs b/StabilityMatrix/Services/IDownloadService.cs index c54c9d49..8120e213 100644 --- a/StabilityMatrix/Services/IDownloadService.cs +++ b/StabilityMatrix/Services/IDownloadService.cs @@ -6,6 +6,6 @@ namespace StabilityMatrix.Services; public interface IDownloadService { - Task DownloadToFileAsync(string downloadUrl, string downloadLocation, int bufferSize = ushort.MaxValue, + Task DownloadToFileAsync(string downloadUrl, string downloadLocation, IProgress? progress = null, string? httpClientName = null); }