Fixed: Completed Download HealthCheck not working

closes #200
pull/6/head
Qstick 7 years ago
parent 499b222514
commit d53b983c91

@ -1,9 +1,7 @@
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.HealthCheck.Checks; using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.HealthCheck.Checks namespace NzbDrone.Core.Test.HealthCheck.Checks
{ {
@ -15,10 +13,6 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
{ {
if (enabled.HasValue) if (enabled.HasValue)
{ {
Mocker.GetMock<IConfigService>()
.Setup(s => s.IsDefined("EnableCompletedDownloadHandling"))
.Returns(true);
Mocker.GetMock<IConfigService>() Mocker.GetMock<IConfigService>()
.SetupGet(s => s.EnableCompletedDownloadHandling) .SetupGet(s => s.EnableCompletedDownloadHandling)
.Returns(enabled.Value); .Returns(enabled.Value);
@ -26,13 +20,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
} }
[Test] [Test]
public void should_return_warning_when_completed_download_handling_not_configured() public void should_return_warning_when_completeddownloadhandling_false()
{
Subject.Check().ShouldBeWarning();
}
[Test]
public void should_return_warning_when_both_completeddownloadhandling_and_dronefactory_are_not_configured()
{ {
GivenCompletedDownloadHandling(false); GivenCompletedDownloadHandling(false);

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Download.Clients.Sabnzbd;
using NzbDrone.Core.ThingiProvider.Events; using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks namespace NzbDrone.Core.HealthCheck.Checks
@ -17,56 +11,15 @@ namespace NzbDrone.Core.HealthCheck.Checks
public class ImportMechanismCheck : HealthCheckBase public class ImportMechanismCheck : HealthCheckBase
{ {
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly IProvideDownloadClient _provideDownloadClient;
public ImportMechanismCheck(IConfigService configService, IProvideDownloadClient provideDownloadClient) public ImportMechanismCheck(IConfigService configService)
{ {
_configService = configService; _configService = configService;
_provideDownloadClient = provideDownloadClient;
} }
public override HealthCheck Check() public override HealthCheck Check()
{ {
List<ImportMechanismCheckStatus> downloadClients;
try
{
downloadClients = _provideDownloadClient.GetDownloadClients().Select(v => new ImportMechanismCheckStatus
{
DownloadClient = v,
Status = v.GetStatus()
}).ToList();
}
catch (Exception)
{
// One or more download clients failed, assume the health is okay and verify later
return new HealthCheck(GetType());
}
var downloadClientIsLocalHost = downloadClients.All(v => v.Status.IsLocalhost);
if (!_configService.IsDefined("EnableCompletedDownloadHandling"))
{
// Migration helper logic
if (!downloadClientIsLocalHost)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Multi-Computer unsupported)", "Migrating-to-Completed-Download-Handling#Unsupported-download-client-on-different-computer");
}
if (downloadClients.All(v => v.DownloadClient is Sabnzbd))
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "Migrating-to-Completed-Download-Handling#sabnzbd-enable-completed-download-handling");
}
if (downloadClients.All(v => v.DownloadClient is Nzbget))
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "Migrating-to-Completed-Download-Handling#nzbget-enable-completed-download-handling");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling");
}
if (!_configService.EnableCompletedDownloadHandling) if (!_configService.EnableCompletedDownloadHandling)
{ {
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling"); return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling");

Loading…
Cancel
Save