This commit is contained in:
Archi
2024-03-09 23:57:47 +01:00
parent d30dcb569d
commit bccd1bb2b8

View File

@@ -177,22 +177,18 @@ public sealed class WebBrowser : IDisposable {
while (response.Content.CanRead) {
int read = await response.Content.ReadAsync(buffer.AsMemory(0, buffer.Length), cancellationToken).ConfigureAwait(false);
if (read == 0) {
if (read <= 0) {
break;
}
await ms.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false);
if ((progressReporter == null) || (batchIncreaseSize == 0) || (batch >= 99)) {
continue;
}
readThisBatch += read;
while ((readThisBatch >= batchIncreaseSize) && (batch < 99)) {
readThisBatch -= batchIncreaseSize;
progressReporter.Report(++batch);
progressReporter?.Report(++batch);
}
await ms.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false);
}
} catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) {
throw;