mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Fixed: DownloadClientRootFolderCheck Improvements
This commit is contained in:
parent
94d7f56743
commit
9cbc771b93
2 changed files with 36 additions and 4 deletions
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download
|
||||||
public interface IProvideDownloadClient
|
public interface IProvideDownloadClient
|
||||||
{
|
{
|
||||||
IDownloadClient GetDownloadClient(DownloadProtocol downloadProtocol, int indexerId = 0);
|
IDownloadClient GetDownloadClient(DownloadProtocol downloadProtocol, int indexerId = 0);
|
||||||
IEnumerable<IDownloadClient> GetDownloadClients();
|
IEnumerable<IDownloadClient> GetDownloadClients(bool filterBlockedClients = false);
|
||||||
IDownloadClient Get(int id);
|
IDownloadClient Get(int id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,14 +86,39 @@ namespace NzbDrone.Core.Download
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IDownloadClient> GetDownloadClients()
|
public IEnumerable<IDownloadClient> GetDownloadClients(bool filterBlockedClients = false)
|
||||||
{
|
{
|
||||||
return _downloadClientFactory.GetAvailableProviders();
|
var enabledClients = _downloadClientFactory.GetAvailableProviders();
|
||||||
|
|
||||||
|
if (filterBlockedClients)
|
||||||
|
{
|
||||||
|
return FilterBlockedIndexers(enabledClients).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabledClients;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDownloadClient Get(int id)
|
public IDownloadClient Get(int id)
|
||||||
{
|
{
|
||||||
return _downloadClientFactory.GetAvailableProviders().Single(d => d.Definition.Id == id);
|
return _downloadClientFactory.GetAvailableProviders().Single(d => d.Definition.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<IDownloadClient> FilterBlockedIndexers(IEnumerable<IDownloadClient> clients)
|
||||||
|
{
|
||||||
|
var blockedClients = _downloadClientStatusService.GetBlockedProviders().ToDictionary(v => v.ProviderId, v => v);
|
||||||
|
|
||||||
|
foreach (var client in clients)
|
||||||
|
{
|
||||||
|
DownloadClientStatus blockedClientStatus;
|
||||||
|
|
||||||
|
if (blockedClients.TryGetValue(client.Definition.Id, out blockedClientStatus))
|
||||||
|
{
|
||||||
|
_logger.Debug("Temporarily ignoring client {0} till {1} due to recent failures.", client.Definition.Name, blockedClientStatus.DisabledTill.Value.ToLocalTime());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return client;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
|
@ -34,7 +35,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
|
|
||||||
public override HealthCheck Check()
|
public override HealthCheck Check()
|
||||||
{
|
{
|
||||||
var clients = _downloadClientProvider.GetDownloadClients();
|
// Only check clients not in failure status, those get another message
|
||||||
|
var clients = _downloadClientProvider.GetDownloadClients(true);
|
||||||
|
|
||||||
var rootFolders = _rootFolderService.All();
|
var rootFolders = _rootFolderService.All();
|
||||||
|
|
||||||
foreach (var client in clients)
|
foreach (var client in clients)
|
||||||
|
@ -55,6 +58,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
{
|
{
|
||||||
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Unknown error occurred in DownloadClientRootFolderCheck HealthCheck");
|
_logger.Error(ex, "Unknown error occurred in DownloadClientRootFolderCheck HealthCheck");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue