Allow DownloadMonitoring to report client status

pull/4415/head
Qstick 5 years ago
parent 91ed949a47
commit cb97f90b9e

@ -18,7 +18,8 @@ namespace NzbDrone.Core.Download.TrackedDownloads
IHandle<DownloadsProcessedEvent>, IHandle<DownloadsProcessedEvent>,
IHandle<TrackedDownloadsRemovedEvent> IHandle<TrackedDownloadsRemovedEvent>
{ {
private readonly IProvideDownloadClient _downloadClientProvider; private readonly IDownloadClientStatusService _downloadClientStatusService;
private readonly IDownloadClientFactory _downloadClientFactory;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IManageCommandQueue _manageCommandQueue; private readonly IManageCommandQueue _manageCommandQueue;
private readonly IConfigService _configService; private readonly IConfigService _configService;
@ -28,7 +29,8 @@ namespace NzbDrone.Core.Download.TrackedDownloads
private readonly Logger _logger; private readonly Logger _logger;
private readonly Debouncer _refreshDebounce; private readonly Debouncer _refreshDebounce;
public DownloadMonitoringService(IProvideDownloadClient downloadClientProvider, public DownloadMonitoringService(IDownloadClientStatusService downloadClientStatusService,
IDownloadClientFactory downloadClientFactory,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
IManageCommandQueue manageCommandQueue, IManageCommandQueue manageCommandQueue,
IConfigService configService, IConfigService configService,
@ -37,7 +39,8 @@ namespace NzbDrone.Core.Download.TrackedDownloads
ITrackedDownloadService trackedDownloadService, ITrackedDownloadService trackedDownloadService,
Logger logger) Logger logger)
{ {
_downloadClientProvider = downloadClientProvider; _downloadClientStatusService = downloadClientStatusService;
_downloadClientFactory = downloadClientFactory;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_manageCommandQueue = manageCommandQueue; _manageCommandQueue = manageCommandQueue;
_configService = configService; _configService = configService;
@ -59,7 +62,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
_refreshDebounce.Pause(); _refreshDebounce.Pause();
try try
{ {
var downloadClients = _downloadClientProvider.GetDownloadClients(); var downloadClients = _downloadClientFactory.DownloadHandlingEnabled();
var trackedDownloads = new List<TrackedDownload>(); var trackedDownloads = new List<TrackedDownload>();
@ -88,9 +91,13 @@ namespace NzbDrone.Core.Download.TrackedDownloads
try try
{ {
downloadClientItems = downloadClient.GetItems().ToList(); downloadClientItems = downloadClient.GetItems().ToList();
_downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id);
} }
catch (Exception ex) catch (Exception ex)
{ {
// TODO: Stop tracking items for the offline client
_downloadClientStatusService.RecordFailure(downloadClient.Definition.Id);
_logger.Warn(ex, "Unable to retrieve queue and history items from " + downloadClient.Definition.Name); _logger.Warn(ex, "Unable to retrieve queue and history items from " + downloadClient.Definition.Name);
} }

Loading…
Cancel
Save