From c99d81e79ba5e6ecec01ddd942440d8a48a1c23b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 26 Feb 2024 20:56:59 -0800 Subject: [PATCH] New: Bypass archived history for failed downloads in SABnzbd --- .../Download/Clients/Sabnzbd/Sabnzbd.cs | 4 ++-- .../Download/Clients/Sabnzbd/SabnzbdProxy.cs | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index 8beaa97a2..b0a4e2495 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -205,11 +205,11 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd DeleteItemData(item); } - _proxy.RemoveFrom("history", item.DownloadId, deleteData, Settings); + _proxy.RemoveFromHistory(item.DownloadId, deleteData, item.Status == DownloadItemStatus.Failed, Settings); } else { - _proxy.RemoveFrom("queue", item.DownloadId, deleteData, Settings); + _proxy.RemoveFromQueue(item.DownloadId, deleteData, Settings); } } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdProxy.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdProxy.cs index da0f8f2aa..73736fbbc 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdProxy.cs @@ -14,7 +14,8 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd { string GetBaseUrl(SabnzbdSettings settings, string relativePath = null); SabnzbdAddResponse DownloadNzb(byte[] nzbData, string filename, string category, int priority, SabnzbdSettings settings); - void RemoveFrom(string source, string id, bool deleteData, SabnzbdSettings settings); + void RemoveFromQueue(string id, bool deleteData, SabnzbdSettings settings); + void RemoveFromHistory(string id, bool deleteData, bool deletePermanently, SabnzbdSettings settings); string GetVersion(SabnzbdSettings settings); SabnzbdConfig GetConfig(SabnzbdSettings settings); SabnzbdFullStatus GetFullStatus(SabnzbdSettings settings); @@ -60,9 +61,9 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd return response; } - public void RemoveFrom(string source, string id, bool deleteData, SabnzbdSettings settings) + public void RemoveFromQueue(string id, bool deleteData, SabnzbdSettings settings) { - var request = BuildRequest(source, settings); + var request = BuildRequest("queue", settings); request.AddQueryParam("name", "delete"); request.AddQueryParam("del_files", deleteData ? 1 : 0); request.AddQueryParam("value", id); @@ -70,6 +71,17 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd ProcessRequest(request, settings); } + public void RemoveFromHistory(string id, bool deleteData, bool deletePermanently, SabnzbdSettings settings) + { + var request = BuildRequest("history", settings); + request.AddQueryParam("name", "delete"); + request.AddQueryParam("del_files", deleteData ? 1 : 0); + request.AddQueryParam("value", id); + request.AddQueryParam("archive", deletePermanently ? 0 : 1); + + ProcessRequest(request, settings); + } + public string GetVersion(SabnzbdSettings settings) { var request = BuildRequest("version", settings);