From 3f0457b7db1c0cab1afce8b91839796d313711bb Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 30 Jan 2022 19:50:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Aria=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/Aria2cNet/AriaManager.cs | 20 ++++++++++++++------ DownKyi.Core/Aria2cNet/Client/AriaClient.cs | 9 +++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/DownKyi.Core/Aria2cNet/AriaManager.cs b/DownKyi.Core/Aria2cNet/AriaManager.cs index c40e2cc..da2b555 100644 --- a/DownKyi.Core/Aria2cNet/AriaManager.cs +++ b/DownKyi.Core/Aria2cNet/AriaManager.cs @@ -1,7 +1,9 @@ using DownKyi.Core.Aria2cNet.Client; +using DownKyi.Core.Aria2cNet.Client.Entity; using DownKyi.Core.Logging; using System; using System.Threading; +using System.Threading.Tasks; namespace DownKyi.Core.Aria2cNet { @@ -45,7 +47,7 @@ namespace DownKyi.Core.Aria2cNet string filePath = ""; while (true) { - var status = AriaClient.TellStatus(gid); + Task status = AriaClient.TellStatus(gid); if (status == null || status.Result == null) { continue; } if (status.Result.Result == null && status.Result.Error != null) @@ -81,8 +83,11 @@ namespace DownKyi.Core.Aria2cNet } if (status.Result.Result.ErrorCode != null && status.Result.Result.ErrorCode != "0") { - Utils.Debugging.Console.PrintLine("ErrorMessage: " + status.Result.Result.ErrorMessage); - LogManager.Error("AriaManager", status.Result.Result.ErrorMessage); + if (status.Result != null) + { + Utils.Debugging.Console.PrintLine("ErrorMessage: " + status.Result.Result.ErrorMessage); + LogManager.Error("AriaManager", status.Result.Result.ErrorMessage); + } //// 如果返回状态码不是200,则继续 //if (status.Result.Result.ErrorMessage.Contains("The response status is not successful")) @@ -92,9 +97,12 @@ namespace DownKyi.Core.Aria2cNet //} // aira中删除记录 - var ariaRemove1 = AriaClient.RemoveDownloadResultAsync(gid); + Task ariaRemove1 = AriaClient.RemoveDownloadResultAsync(gid); Utils.Debugging.Console.PrintLine(ariaRemove1); - LogManager.Debug("AriaManager", ariaRemove1.Result.Result); + if (ariaRemove1.Result != null) + { + LogManager.Debug("AriaManager", ariaRemove1.Result.Result); + } // 返回回调信息,退出函数 OnDownloadFinish(false, null, gid, status.Result.Result.ErrorMessage); @@ -116,7 +124,7 @@ namespace DownKyi.Core.Aria2cNet while (true) { // 查询全局status - var globalStatus = await AriaClient.GetGlobalStatAsync(); + AriaGetGlobalStat globalStatus = await AriaClient.GetGlobalStatAsync(); if (globalStatus == null || globalStatus.Result == null) { continue; } long globalSpeed = long.Parse(globalStatus.Result.DownloadSpeed); diff --git a/DownKyi.Core/Aria2cNet/Client/AriaClient.cs b/DownKyi.Core/Aria2cNet/Client/AriaClient.cs index a9852cb..77083a4 100644 --- a/DownKyi.Core/Aria2cNet/Client/AriaClient.cs +++ b/DownKyi.Core/Aria2cNet/Client/AriaClient.cs @@ -1093,8 +1093,9 @@ namespace DownKyi.Core.Aria2cNet.Client } catch (WebException e) { - Utils.Debugging.Console.PrintLine("Request()发生Web异常: {0}", e); - LogManager.Error("AriaClient", e); + //Utils.Debugging.Console.PrintLine("Request()发生Web异常: {0}", e); + //LogManager.Error("AriaClient", e); + //return Request(url, parameters, retry - 1); string html = string.Empty; @@ -1108,8 +1109,8 @@ namespace DownKyi.Core.Aria2cNet.Client } } - Console.WriteLine($"本次请求使用的参数:{parameters}"); - Console.WriteLine($"返回的web数据:{html}"); + //Console.WriteLine($"本次请求使用的参数:{parameters}"); + //Console.WriteLine($"返回的web数据:{html}"); return html; } catch (IOException e)