From 2dba5ef4b431bee0a061be67354c9a7a612a03c8 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 15 May 2021 21:37:55 +0200 Subject: [PATCH] New: Per download client setting to Remove Completed/Failed downloads instead of global setting --- frontend/src/Components/FieldSet.css | 5 + frontend/src/Components/FieldSet.js | 10 +- .../EditDownloadClientModalContent.js | 37 +++++- .../Options/DownloadClientOptions.js | 52 +++----- .../Config/DownloadClientConfigResource.cs | 8 +- .../DownloadClient/DownloadClientModule.cs | 4 + .../DownloadClient/DownloadClientResource.cs | 2 + .../158_cdh_per_downloadclientFixture.cs | 119 ++++++++++++++++++ .../Configuration/ConfigService.cs | 14 --- .../Configuration/IConfigService.cs | 3 - .../Migration/158_cdh_per_downloadclient.cs | 51 ++++++++ .../Migration/Framework/MigrationExtension.cs | 14 ++- .../Download/Clients/rTorrent/RTorrent.cs | 2 +- .../Download/DownloadClientDefinition.cs | 3 + .../Download/DownloadEventHub.cs | 58 ++++++--- .../Download/DownloadProcessingService.cs | 6 +- .../Config/DownloadClientConfigResource.cs | 8 +- .../DownloadClient/DownloadClientResource.cs | 6 + 18 files changed, 307 insertions(+), 95 deletions(-) create mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/158_cdh_per_downloadclientFixture.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/158_cdh_per_downloadclient.cs diff --git a/frontend/src/Components/FieldSet.css b/frontend/src/Components/FieldSet.css index daf3bdf2e..6da64f0e0 100644 --- a/frontend/src/Components/FieldSet.css +++ b/frontend/src/Components/FieldSet.css @@ -16,4 +16,9 @@ color: #3a3f51; font-size: 21px; line-height: inherit; + + &.small { + color: #909293; + font-size: 18px; + } } diff --git a/frontend/src/Components/FieldSet.js b/frontend/src/Components/FieldSet.js index 76e68a934..d5f411fbe 100644 --- a/frontend/src/Components/FieldSet.js +++ b/frontend/src/Components/FieldSet.js @@ -1,5 +1,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import classNames from 'classnames'; +import { sizes } from 'Helpers/Props'; import styles from './FieldSet.css'; class FieldSet extends Component { @@ -9,13 +11,14 @@ class FieldSet extends Component { render() { const { + size, legend, children } = this.props; return (
- + {legend} {children} @@ -26,8 +29,13 @@ class FieldSet extends Component { } FieldSet.propTypes = { + size: PropTypes.oneOf(sizes.all).isRequired, legend: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), children: PropTypes.node }; +FieldSet.defaultProps = { + size: sizes.MEDIUM +}; + export default FieldSet; diff --git a/frontend/src/Settings/DownloadClients/DownloadClients/EditDownloadClientModalContent.js b/frontend/src/Settings/DownloadClients/DownloadClients/EditDownloadClientModalContent.js index 174050bad..c57284f76 100644 --- a/frontend/src/Settings/DownloadClients/DownloadClients/EditDownloadClientModalContent.js +++ b/frontend/src/Settings/DownloadClients/DownloadClients/EditDownloadClientModalContent.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { inputTypes, kinds } from 'Helpers/Props'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; import Alert from 'Components/Alert'; import Button from 'Components/Link/Button'; import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; @@ -9,6 +9,7 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; import ModalFooter from 'Components/Modal/ModalFooter'; +import FieldSet from 'Components/FieldSet'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; import FormLabel from 'Components/Form/FormLabel'; @@ -44,7 +45,10 @@ class EditDownloadClientModalContent extends Component { implementationName, name, enable, + protocol, priority, + removeCompletedDownloads, + removeFailedDownloads, fields, message } = item; @@ -133,6 +137,37 @@ class EditDownloadClientModalContent extends Component { /> +
+ + Remove Completed + + + + + { + protocol.value !== 'torrent' && + + Remove Failed + + + + } +
} diff --git a/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js b/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js index c345feb5b..2efe9f4e2 100644 --- a/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js +++ b/frontend/src/Settings/DownloadClients/Options/DownloadClientOptions.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { inputTypes, sizes } from 'Helpers/Props'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; +import Alert from 'Components/Alert'; import FieldSet from 'Components/FieldSet'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import Form from 'Components/Form/Form'; @@ -31,11 +32,16 @@ function DownloadClientOptions(props) { } { - hasSettings && !isFetching && !error && + hasSettings && !isFetching && !error && advancedSettings &&
+
- + Enable - Remove - - - - -
- -
-
- - Redownload + Redownload Failed - - - Remove - - -
+ + + The Remove settings were moved to the individual Download Client settings in the table above. +
} diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs index d0bf6f4a2..b0cdd5cb0 100644 --- a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs +++ b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs @@ -8,10 +8,7 @@ namespace NzbDrone.Api.Config public string DownloadClientWorkingFolders { get; set; } public bool EnableCompletedDownloadHandling { get; set; } - public bool RemoveCompletedDownloads { get; set; } - public bool AutoRedownloadFailed { get; set; } - public bool RemoveFailedDownloads { get; set; } } public static class DownloadClientConfigResourceMapper @@ -23,10 +20,7 @@ namespace NzbDrone.Api.Config DownloadClientWorkingFolders = model.DownloadClientWorkingFolders, EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling, - RemoveCompletedDownloads = model.RemoveCompletedDownloads, - - AutoRedownloadFailed = model.AutoRedownloadFailed, - RemoveFailedDownloads = model.RemoveFailedDownloads + AutoRedownloadFailed = model.AutoRedownloadFailed }; } } diff --git a/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs b/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs index 8b5ad25d4..561ce58df 100644 --- a/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs +++ b/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs @@ -16,6 +16,8 @@ namespace NzbDrone.Api.DownloadClient resource.Enable = definition.Enable; resource.Protocol = definition.Protocol; resource.Priority = definition.Priority; + resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads; + resource.RemoveFailedDownloads = definition.RemoveFailedDownloads; } protected override void MapToModel(DownloadClientDefinition definition, DownloadClientResource resource) @@ -25,6 +27,8 @@ namespace NzbDrone.Api.DownloadClient definition.Enable = resource.Enable; definition.Protocol = resource.Protocol; definition.Priority = resource.Priority; + definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads; + definition.RemoveFailedDownloads = resource.RemoveFailedDownloads; } protected override void Validate(DownloadClientDefinition definition, bool includeWarnings) diff --git a/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs b/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs index 5e268578b..1065ba747 100644 --- a/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs +++ b/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs @@ -7,5 +7,7 @@ namespace NzbDrone.Api.DownloadClient public bool Enable { get; set; } public DownloadProtocol Protocol { get; set; } public int Priority { get; set; } + public bool RemoveCompletedDownloads { get; set; } + public bool RemoveFailedDownloads { get; set; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/158_cdh_per_downloadclientFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/158_cdh_per_downloadclientFixture.cs new file mode 100644 index 000000000..e79b0b837 --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/158_cdh_per_downloadclientFixture.cs @@ -0,0 +1,119 @@ +using System.Collections.Generic; +using System.Linq; +using FluentAssertions; +using Newtonsoft.Json.Linq; +using NUnit.Framework; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.Datastore.Migration; +using NzbDrone.Core.Download.Clients.RTorrent; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore.Migration +{ + [TestFixture] + public class cdh_per_downloadclientFixture : MigrationTest + { + [Test] + public void should_set_cdh_to_enabled() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("DownloadClients").Row(new + { + Enable = 1, + Name = "Deluge", + Implementation = "Deluge", + Priority = 1, + Settings = new DelugeSettings85 + { + Host = "127.0.0.1", + TvCategory = "abc", + UrlBase = "/my/" + }.ToJson(), + ConfigContract = "DelugeSettings" + }); + }); + + var items = db.Query("SELECT * FROM DownloadClients"); + + items.Should().HaveCount(1); + items.First().RemoveCompletedDownloads.Should().BeTrue(); + items.First().RemoveFailedDownloads.Should().BeFalse(); + } + + [Test] + public void should_set_cdh_to_disabled_when_globally_disabled() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("Config").Row(new + { + Key = "removecompleteddownloads", + Value = "False" + }); + + c.Insert.IntoTable("DownloadClients").Row(new + { + Enable = 1, + Name = "Deluge", + Implementation = "Deluge", + Priority = 1, + Settings = new DelugeSettings85 + { + Host = "127.0.0.1", + TvCategory = "abc", + UrlBase = "/my/" + }.ToJson(), + ConfigContract = "DelugeSettings" + }); + }); + + var items = db.Query("SELECT * FROM DownloadClients"); + + items.Should().HaveCount(1); + items.First().RemoveCompletedDownloads.Should().BeFalse(); + items.First().RemoveFailedDownloads.Should().BeFalse(); + } + + [Test] + public void should_disable_remove_for_existing_rtorrent() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("DownloadClients").Row(new + { + Enable = 1, + Name = "RTorrent", + Implementation = "RTorrent", + Priority = 1, + Settings = new RTorrentSettings + { + Host = "127.0.0.1", + TvCategory = "abc", + UrlBase = "/my/" + }.ToJson(), + ConfigContract = "RTorrentSettings" + }); + }); + + var items = db.Query("SELECT * FROM DownloadClients"); + + items.Should().HaveCount(1); + items.First().RemoveCompletedDownloads.Should().BeFalse(); + items.First().RemoveFailedDownloads.Should().BeFalse(); + } + } + + public class DownloadClientDefinition158 + { + public int Id { get; set; } + public bool Enable { get; set; } + public int Priority { get; set; } + public string Name { get; set; } + public string Implementation { get; set; } + public JObject Settings { get; set; } + public string ConfigContract { get; set; } + public bool RemoveCompletedDownloads { get; set; } + public bool RemoveFailedDownloads { get; set; } + } +} diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index d2844ccbe..8cbbaff2d 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -134,13 +134,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("EnableCompletedDownloadHandling", value); } } - public bool RemoveCompletedDownloads - { - get { return GetValueBoolean("RemoveCompletedDownloads", false); } - - set { SetValue("RemoveCompletedDownloads", value); } - } - public bool AutoRedownloadFailed { get { return GetValueBoolean("AutoRedownloadFailed", true); } @@ -148,13 +141,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("AutoRedownloadFailed", value); } } - public bool RemoveFailedDownloads - { - get { return GetValueBoolean("RemoveFailedDownloads", true); } - - set { SetValue("RemoveFailedDownloads", value); } - } - public bool CreateEmptySeriesFolders { get { return GetValueBoolean("CreateEmptySeriesFolders", false); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index ad3bef22c..3ef1fbf93 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -19,10 +19,7 @@ namespace NzbDrone.Core.Configuration //Completed/Failed Download Handling (Download client) bool EnableCompletedDownloadHandling { get; set; } - bool RemoveCompletedDownloads { get; set; } - bool AutoRedownloadFailed { get; set; } - bool RemoveFailedDownloads { get; set; } //Media Management bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; } diff --git a/src/NzbDrone.Core/Datastore/Migration/158_cdh_per_downloadclient.cs b/src/NzbDrone.Core/Datastore/Migration/158_cdh_per_downloadclient.cs new file mode 100644 index 000000000..c26e33a72 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/158_cdh_per_downloadclient.cs @@ -0,0 +1,51 @@ +using System.Data; +using System.Linq; +using FluentMigrator; +using Newtonsoft.Json.Linq; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(158)] + public class cdh_per_downloadclient : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("DownloadClients") + .AddColumn("RemoveCompletedDownloads").AsBoolean().NotNullable().WithDefaultValue(true) + .AddColumn("RemoveFailedDownloads").AsBoolean().NotNullable().WithDefaultValue(true); + + Execute.WithConnection(MoveRemoveSettings); + } + + private void MoveRemoveSettings(IDbConnection conn, IDbTransaction tran) + { + var removeCompletedDownloads = true; + var removeFailedDownloads = false; + + using (var removeCompletedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removecompleteddownloads'")) + { + if ("False" == (removeCompletedDownloadsCmd.ExecuteScalar() as string)) + removeCompletedDownloads = false; + } + + using (var removeFailedDownloadsCmd = conn.CreateCommand(tran, "SELECT Value FROM Config WHERE Key = 'removefaileddownloads'")) + { + if ("True" == (removeFailedDownloadsCmd.ExecuteScalar() as string)) + removeFailedDownloads = true; + } + + using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation = \"RTorrent\" THEN 0 ELSE ? END), RemoveFailedDownloads = ?")) + { + updateClientCmd.AddParameter(removeCompletedDownloads ? 1 : 0); + updateClientCmd.AddParameter(removeFailedDownloads ? 1 : 0); + updateClientCmd.ExecuteNonQuery(); + } + using (var removeConfigCmd = conn.CreateCommand(tran, $"DELETE FROM Config WHERE Key IN ('removecompleteddownloads', 'removefaileddownloads')")) + { + removeConfigCmd.ExecuteNonQuery(); + } + } + } +} diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/MigrationExtension.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/MigrationExtension.cs index 807e73e2a..24a63f2ad 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/MigrationExtension.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/MigrationExtension.cs @@ -1,4 +1,5 @@ -using FluentMigrator.Builders.Create; +using System.Data; +using FluentMigrator.Builders.Create; using FluentMigrator.Builders.Create.Table; namespace NzbDrone.Core.Datastore.Migration.Framework @@ -10,7 +11,16 @@ namespace NzbDrone.Core.Datastore.Migration.Framework return expressionRoot.Table(name).WithColumn("Id").AsInt32().PrimaryKey().Identity(); } - public static void AddParameter(this System.Data.IDbCommand command, object value) + public static IDbCommand CreateCommand(this IDbConnection conn, IDbTransaction tran, string query) + { + var command = conn.CreateCommand(); + command.Transaction = tran; + command.CommandText = query; + + return command; + } + + public static void AddParameter(this IDbCommand command, object value) { var parameter = command.CreateParameter(); parameter.Value = value; diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index a9a2594b4..19ec9e515 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -168,7 +168,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent // Check if torrent is finished and if it exceeds cached seedConfig item.CanMoveFiles = item.CanBeRemoved = - torrent.IsFinished && + torrent.IsFinished && seedConfig != null && ( (torrent.Ratio / 1000.0) >= seedConfig.Ratio || (DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds(torrent.FinishedTime)) >= seedConfig.SeedTime diff --git a/src/NzbDrone.Core/Download/DownloadClientDefinition.cs b/src/NzbDrone.Core/Download/DownloadClientDefinition.cs index 1c0dfa927..6de6a4f14 100644 --- a/src/NzbDrone.Core/Download/DownloadClientDefinition.cs +++ b/src/NzbDrone.Core/Download/DownloadClientDefinition.cs @@ -7,5 +7,8 @@ namespace NzbDrone.Core.Download { public DownloadProtocol Protocol { get; set; } public int Priority { get; set; } = 1; + + public bool RemoveCompletedDownloads { get; set; } = true; + public bool RemoveFailedDownloads { get; set; } = true; } } diff --git a/src/NzbDrone.Core/Download/DownloadEventHub.cs b/src/NzbDrone.Core/Download/DownloadEventHub.cs index 3feb31cd5..a1e4a6856 100644 --- a/src/NzbDrone.Core/Download/DownloadEventHub.cs +++ b/src/NzbDrone.Core/Download/DownloadEventHub.cs @@ -27,38 +27,65 @@ namespace NzbDrone.Core.Download { var trackedDownload = message.TrackedDownload; - if (trackedDownload == null || !trackedDownload.DownloadItem.CanBeRemoved || _configService.RemoveFailedDownloads == false) + if (trackedDownload == null || + message.TrackedDownload.DownloadItem.Removed || + !trackedDownload.DownloadItem.CanBeRemoved) { return; } - RemoveFromDownloadClient(trackedDownload); + var downloadClient = _downloadClientProvider.Get(message.TrackedDownload.DownloadClient); + var definition = downloadClient.Definition as DownloadClientDefinition; + + if (!definition.RemoveFailedDownloads) + { + return; + } + + RemoveFromDownloadClient(trackedDownload, downloadClient); } public void Handle(DownloadCompletedEvent message) { - if (_configService.RemoveCompletedDownloads && - !message.TrackedDownload.DownloadItem.Removed && - message.TrackedDownload.DownloadItem.CanBeRemoved && - message.TrackedDownload.DownloadItem.Status != DownloadItemStatus.Downloading) + var trackedDownload = message.TrackedDownload; + var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); + var definition = downloadClient.Definition as DownloadClientDefinition; + + MarkItemAsImported(trackedDownload, downloadClient); + + if (trackedDownload.DownloadItem.Removed || + !trackedDownload.DownloadItem.CanBeRemoved || + trackedDownload.DownloadItem.Status == DownloadItemStatus.Downloading) { - RemoveFromDownloadClient(message.TrackedDownload); + return; } - else + + if (!definition.RemoveCompletedDownloads) { - MarkItemAsImported(message.TrackedDownload); - } + return; + } + + RemoveFromDownloadClient(message.TrackedDownload, downloadClient); } public void Handle(DownloadCanBeRemovedEvent message) { - // Already verified that it can be removed, just needs to be removed - RemoveFromDownloadClient(message.TrackedDownload); + var trackedDownload = message.TrackedDownload; + var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); + var definition = downloadClient.Definition as DownloadClientDefinition; + + if (trackedDownload.DownloadItem.Removed || + !trackedDownload.DownloadItem.CanBeRemoved || + !definition.RemoveCompletedDownloads) + { + return; + } + + RemoveFromDownloadClient(message.TrackedDownload, downloadClient); } - private void RemoveFromDownloadClient(TrackedDownload trackedDownload) + private void RemoveFromDownloadClient(TrackedDownload trackedDownload, IDownloadClient downloadClient) { - var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); try { _logger.Debug("[{0}] Removing download from {1} history", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name); @@ -75,9 +102,8 @@ namespace NzbDrone.Core.Download } } - private void MarkItemAsImported(TrackedDownload trackedDownload) + private void MarkItemAsImported(TrackedDownload trackedDownload, IDownloadClient downloadClient) { - var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); try { _logger.Debug("[{0}] Marking download as imported from {1}", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name); diff --git a/src/NzbDrone.Core/Download/DownloadProcessingService.cs b/src/NzbDrone.Core/Download/DownloadProcessingService.cs index c1c78895e..b6183aece 100644 --- a/src/NzbDrone.Core/Download/DownloadProcessingService.cs +++ b/src/NzbDrone.Core/Download/DownloadProcessingService.cs @@ -48,7 +48,6 @@ namespace NzbDrone.Core.Download public void Execute(ProcessMonitoredDownloadsCommand message) { var enableCompletedDownloadHandling = _configService.EnableCompletedDownloadHandling; - var removeCompletedDownloads = _configService.RemoveCompletedDownloads; var trackedDownloads = _trackedDownloadService.GetTrackedDownloads() .Where(t => t.IsTrackable) .ToList(); @@ -73,10 +72,7 @@ namespace NzbDrone.Core.Download } // Imported downloads are no longer trackable so process them after processing trackable downloads - if (removeCompletedDownloads) - { - RemoveCompletedDownloads(); - } + RemoveCompletedDownloads(); _eventAggregator.PublishEvent(new DownloadsProcessedEvent()); } diff --git a/src/Sonarr.Api.V3/Config/DownloadClientConfigResource.cs b/src/Sonarr.Api.V3/Config/DownloadClientConfigResource.cs index a749510b3..17c98e660 100644 --- a/src/Sonarr.Api.V3/Config/DownloadClientConfigResource.cs +++ b/src/Sonarr.Api.V3/Config/DownloadClientConfigResource.cs @@ -8,10 +8,7 @@ namespace Sonarr.Api.V3.Config public string DownloadClientWorkingFolders { get; set; } public bool EnableCompletedDownloadHandling { get; set; } - public bool RemoveCompletedDownloads { get; set; } - public bool AutoRedownloadFailed { get; set; } - public bool RemoveFailedDownloads { get; set; } } public static class DownloadClientConfigResourceMapper @@ -23,10 +20,7 @@ namespace Sonarr.Api.V3.Config DownloadClientWorkingFolders = model.DownloadClientWorkingFolders, EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling, - RemoveCompletedDownloads = model.RemoveCompletedDownloads, - - AutoRedownloadFailed = model.AutoRedownloadFailed, - RemoveFailedDownloads = model.RemoveFailedDownloads + AutoRedownloadFailed = model.AutoRedownloadFailed }; } } diff --git a/src/Sonarr.Api.V3/DownloadClient/DownloadClientResource.cs b/src/Sonarr.Api.V3/DownloadClient/DownloadClientResource.cs index 43efc111a..713496537 100644 --- a/src/Sonarr.Api.V3/DownloadClient/DownloadClientResource.cs +++ b/src/Sonarr.Api.V3/DownloadClient/DownloadClientResource.cs @@ -8,6 +8,8 @@ namespace Sonarr.Api.V3.DownloadClient public bool Enable { get; set; } public DownloadProtocol Protocol { get; set; } public int Priority { get; set; } + public bool RemoveCompletedDownloads { get; set; } + public bool RemoveFailedDownloads { get; set; } } public class DownloadClientResourceMapper : ProviderResourceMapper @@ -21,6 +23,8 @@ namespace Sonarr.Api.V3.DownloadClient resource.Enable = definition.Enable; resource.Protocol = definition.Protocol; resource.Priority = definition.Priority; + resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads; + resource.RemoveFailedDownloads = definition.RemoveFailedDownloads; return resource; } @@ -34,6 +38,8 @@ namespace Sonarr.Api.V3.DownloadClient definition.Enable = resource.Enable; definition.Protocol = resource.Protocol; definition.Priority = resource.Priority; + definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads; + definition.RemoveFailedDownloads = resource.RemoveFailedDownloads; return definition; }