From 270bc9b955c741e1a57eb0b4999fe557d57d0f56 Mon Sep 17 00:00:00 2001 From: Marcelo Castagna Date: Wed, 1 Mar 2017 14:46:16 -0300 Subject: [PATCH 1/2] Fixed: DownloadStation interface stuck in infinite loop in some cases. * removed empty spaces. changed dcaex => ex * Changed error message * changed error message * Wrong message, ups * Another message --- .../Proxies/DiskStationProxyBase.cs | 18 ++++++++++++------ .../DownloadStation/TorrentDownloadStation.cs | 19 +++++++++++++++++-- .../DownloadStation/UsenetDownloadStation.cs | 19 +++++++++++++++++-- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs index 7a6538970..edaa2ebf6 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies { if (retries == 5) { - throw new DownloadClientException("Try to process same request more than 5 times"); + throw new DownloadClientException("Try to process request to {0} with {1} more than 5 times", api, arguments.ToJson().ToString()); } if (!_authenticated && api != DiskStationApi.Info && api != DiskStationApi.DSMInfo) @@ -72,15 +72,21 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies } else { + var msg = $"Failed to {operation}. Reason: {responseContent.Error.GetMessage(api)}"; + _logger.Error(msg); + if (responseContent.Error.SessionError) { _authenticated = false; - return ProcessRequest(api, arguments, settings, operation, method, retries++); - } - - var msg = $"Failed to {operation}. Reason: {responseContent.Error.GetMessage(api)}"; - _logger.Error(msg); + if (responseContent.Error.Code == 105) + { + throw new DownloadClientAuthenticationException(msg); + } + + return ProcessRequest(api, arguments, settings, operation, method, ++retries); + } + throw new DownloadClientException(msg); } } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index 33008530a..8378a6815 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -272,7 +272,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation { try { - var downloadDir = GetDownloadDirectory(); + var downloadDir = GetDefaultDir(); + + if (downloadDir == null) + { + return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination") + { + DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location." + }; + } + + downloadDir = GetDownloadDirectory(); if (downloadDir != null) { @@ -285,7 +295,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation { return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist") { - DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" + DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" }; } @@ -300,6 +310,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation return null; } + catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation + { + _logger.Error(ex); + return new NzbDroneValidationFailure(string.Empty, ex.Message); + } catch (Exception ex) { _logger.Error(ex); diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 27dacf370..ccbe4f75e 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -190,7 +190,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation { try { - var downloadDir = GetDownloadDirectory(); + var downloadDir = GetDefaultDir(); + + if (downloadDir == null) + { + return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination") + { + DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location." + }; + } + + downloadDir = GetDownloadDirectory(); if (downloadDir != null) { @@ -203,7 +213,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation { return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist") { - DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" + DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" }; } @@ -218,6 +228,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation return null; } + catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation + { + _logger.Error(ex); + return new NzbDroneValidationFailure(string.Empty, ex.Message); + } catch (Exception ex) { _logger.Error(ex); From 0cffd851f33675f2842b8eae3dbebd3b151d6a42 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Mon, 6 Mar 2017 20:12:37 +0100 Subject: [PATCH 2/2] Fixed: Deluge 1.3.14 API support due to changed json-rpc checks. fixes #1738 --- src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs b/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs index 518ad7664..3722fd9ce 100644 --- a/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs +++ b/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Common.Http public class JsonRpcRequestBuilder : HttpRequestBuilder { public static HttpAccept JsonRpcHttpAccept = new HttpAccept("application/json-rpc, application/json"); - public static string JsonRpcContentType = "application/json-rpc"; + public static string JsonRpcContentType = "application/json"; public string JsonMethod { get; private set; } public List JsonParameters { get; private set; }