From e0f9ea965ee5b478bf73c57478df621d4db23174 Mon Sep 17 00:00:00 2001 From: bezzad Date: Sat, 18 Nov 2023 22:16:01 +0330 Subject: [PATCH] prevent download completed successfully when Task.WhenAll has aggregated error --- src/Downloader/DownloadService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Downloader/DownloadService.cs b/src/Downloader/DownloadService.cs index 03f5046..7dd3bdc 100644 --- a/src/Downloader/DownloadService.cs +++ b/src/Downloader/DownloadService.cs @@ -142,7 +142,13 @@ private void SetSingleChunkDownload() private async Task ParallelDownload(PauseToken pauseToken) { var tasks = GetChunksTasks(pauseToken); - await Task.WhenAll(tasks).ConfigureAwait(false); + var result = Task.WhenAll(tasks); + await result.ConfigureAwait(false); + + if (result.IsFaulted) + { + throw result.Exception; + } } private async Task SerialDownload(PauseToken pauseToken)