From a13d3c1f7a8ddf0eedf10cbfff097e7c3ecdb3a2 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sat, 29 Oct 2022 18:02:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96cancel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE/Util/DownloadUtil.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/N_m3u8DL-RE/Util/DownloadUtil.cs b/src/N_m3u8DL-RE/Util/DownloadUtil.cs index e7360ce..c8f2ca8 100644 --- a/src/N_m3u8DL-RE/Util/DownloadUtil.cs +++ b/src/N_m3u8DL-RE/Util/DownloadUtil.cs @@ -64,7 +64,6 @@ namespace N_m3u8DL_RE.Util if (speedContainer.ShouldStop) { cancellationTokenSource.Cancel(); - speedContainer.ResetLowSpeedCount(); Logger.DebugMarkUp("Cancel..."); break; } @@ -105,7 +104,7 @@ namespace N_m3u8DL_RE.Util while ((size = await responseStream.ReadAsync(buffer, cancellationTokenSource.Token)) > 0) { speedContainer.Add(size); - await stream.WriteAsync(buffer, 0, size); + await stream.WriteAsync(buffer, 0, size, cancellationTokenSource.Token); } return new DownloadResult() @@ -117,6 +116,7 @@ namespace N_m3u8DL_RE.Util } catch (OperationCanceledException oce) when (oce.CancellationToken == cancellationTokenSource.Token) { + speedContainer.ResetLowSpeedCount(); throw new Exception("Download speed too slow!"); } }