From 033f83465f0e0de37fc26bb82d4afdbd87555df1 Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Sat, 21 Mar 2020 12:05:42 +0800 Subject: [PATCH] Simplify code and clarify speed unit --- v2rayN/v2rayN/Handler/DownloadHandle.cs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index 19630bf7..b4958bfe 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -235,27 +235,12 @@ namespace v2rayN.Handler { if (UpdateCompleted != null) { - if (e.Cancelled) - { - ((WebClientEx)sender).Dispose(); - TimeSpan ts = (DateTime.Now - totalDatetime); - string speed = string.Format("<{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##")); - UpdateCompleted(this, new ResultEventArgs(true, speed)); - return; - } - - if (e.Error == null - || Utils.IsNullOrEmpty(e.Error.ToString())) - { + if (e.Error != null) throw e.Error; - TimeSpan ts = (DateTime.Now - totalDatetime); - string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##")); - UpdateCompleted(this, new ResultEventArgs(true, speed)); - } - else - { - throw e.Error; - } + ((WebClientEx)sender).Dispose(); + TimeSpan ts = (DateTime.Now - totalDatetime); + string speed = string.Format("<{0} MB/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##")); + UpdateCompleted(this, new ResultEventArgs(true, speed)); } } catch (Exception ex)