From 970f064ab49dd231c84d16132b41c19ba23aea6a Mon Sep 17 00:00:00 2001 From: bezzad Date: Sat, 11 Nov 2023 21:04:37 +0330 Subject: [PATCH] throw exception on write new packet when the watcher of ConcurrentStream dead with error --- src/Downloader/ConcurrentStream.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Downloader/ConcurrentStream.cs b/src/Downloader/ConcurrentStream.cs index e51fa3b..b40b87e 100644 --- a/src/Downloader/ConcurrentStream.cs +++ b/src/Downloader/ConcurrentStream.cs @@ -120,6 +120,9 @@ public async Task WriteAsync(long position, byte[] bytes, int length) if (bytes.Length < length) throw new ArgumentOutOfRangeException(nameof(length)); + if(IsFaulted && Exception is not null) + throw Exception; + await _inputBuffer.TryAdd(new Packet(position, bytes, length)); }