diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs index 1a38e7388..d8f4df611 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NzbDrone.Common.Disk; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients; using NzbDrone.Core.HealthCheck.Checks; @@ -70,6 +71,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks .Setup(s => s.GetDownloadClients()) .Returns(new IDownloadClient[] { _downloadClient.Object }); + Mocker.GetMock() + .Setup(s => s.EnableCompletedDownloadHandling) + .Returns(true); + Mocker.GetMock() .Setup(x => x.FolderExists(It.IsAny())) .Returns((string path) => diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index c121a6a71..3d0fd8770 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -196,13 +196,22 @@ namespace NzbDrone.Core.Download.Clients.Deluge public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); + var label = _proxy.GetLabelOptions(Settings); + OsPath destDir; - var destDir = new OsPath(config.GetValueOrDefault("download_location") as string); - - if (config.GetValueOrDefault("move_completed", false).ToString() == "True") + if (label != null && label.ApplyMoveCompleted && label.MoveCompleted) + { + // if label exists and a label completed path exists and is enabled use it instead of global + destDir = new OsPath(label.MoveCompletedPath); + } + else if (config.GetValueOrDefault("move_completed", false).ToString() == "True") { destDir = new OsPath(config.GetValueOrDefault("move_completed_path") as string); } + else + { + destDir = new OsPath(config.GetValueOrDefault("download_location") as string); + } var status = new DownloadClientInfo { diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeLabel.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeLabel.cs new file mode 100644 index 000000000..a5da831ab --- /dev/null +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeLabel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace NzbDrone.Core.Download.Clients.Deluge +{ + public class DelugeLabel + { + [JsonProperty(PropertyName = "apply_move_completed")] + public bool ApplyMoveCompleted { get; set; } + + [JsonProperty(PropertyName = "move_completed")] + public bool MoveCompleted { get; set; } + + [JsonProperty(PropertyName = "move_completed_path")] + public string MoveCompletedPath { get; set; } + } +} diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 21f10b164..370cdffb2 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -19,6 +19,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge string[] GetAvailablePlugins(DelugeSettings settings); string[] GetEnabledPlugins(DelugeSettings settings); string[] GetAvailableLabels(DelugeSettings settings); + DelugeLabel GetLabelOptions(DelugeSettings settings); void SetTorrentLabel(string hash, string label, DelugeSettings settings); void SetTorrentConfiguration(string hash, string key, object value, DelugeSettings settings); void SetTorrentSeedingConfiguration(string hash, TorrentSeedConfiguration seedConfiguration, DelugeSettings settings); @@ -156,6 +157,13 @@ namespace NzbDrone.Core.Download.Clients.Deluge return response; } + public DelugeLabel GetLabelOptions(DelugeSettings settings) + { + var response = ProcessRequest(settings, "label.get_options", settings.MusicCategory); + + return response; + } + public void SetTorrentConfiguration(string hash, string key, object value, DelugeSettings settings) { var arguments = new Dictionary(); diff --git a/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs index 08c723d14..4defb2376 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/RemotePathMappingCheck.cs @@ -5,6 +5,7 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; using NzbDrone.Common.Messaging; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients; @@ -24,22 +25,31 @@ namespace NzbDrone.Core.HealthCheck.Checks { private readonly IDiskProvider _diskProvider; private readonly IProvideDownloadClient _downloadClientProvider; + private readonly IConfigService _configService; private readonly Logger _logger; private readonly IOsInfo _osInfo; public RemotePathMappingCheck(IDiskProvider diskProvider, IProvideDownloadClient downloadClientProvider, + IConfigService configService, IOsInfo osInfo, Logger logger) { _diskProvider = diskProvider; _downloadClientProvider = downloadClientProvider; + _configService = configService; _logger = logger; _osInfo = osInfo; } public override HealthCheck Check() { + // We don't care about client folders if we are not handling completed files + if (!_configService.EnableCompletedDownloadHandling) + { + return new HealthCheck(GetType()); + } + var clients = _downloadClientProvider.GetDownloadClients(); foreach (var client in clients) @@ -101,6 +111,12 @@ namespace NzbDrone.Core.HealthCheck.Checks public HealthCheck Check(IEvent message) { + // We don't care about client folders if we are not handling completed files + if (!_configService.EnableCompletedDownloadHandling) + { + return new HealthCheck(GetType()); + } + if (typeof(TrackImportFailedEvent).IsAssignableFrom(message.GetType())) { var failureMessage = (TrackImportFailedEvent)message;