mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
No longer saving download client for entire the life cycle
This commit is contained in:
parent
e89c337bbe
commit
bc0bd647df
@ -21,8 +21,6 @@ public class FailedDownloadService : IFailedDownloadService, IExecute<FailedDown
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
private readonly IDownloadClient _downloadClient;
|
||||
|
||||
private static string DOWNLOAD_CLIENT = "downloadClient";
|
||||
private static string DOWNLOAD_CLIENT_ID = "downloadClientId";
|
||||
|
||||
@ -37,8 +35,6 @@ public FailedDownloadService(IProvideDownloadClient downloadClientProvider,
|
||||
_eventAggregator = eventAggregator;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
|
||||
_downloadClient = _downloadClientProvider.GetDownloadClient();
|
||||
}
|
||||
|
||||
public void MarkAsFailed(int historyId)
|
||||
@ -64,7 +60,7 @@ private void CheckForFailedDownloads()
|
||||
|
||||
private void CheckQueue(List<History.History> grabbedHistory, List<History.History> failedHistory)
|
||||
{
|
||||
var downloadClientQueue = _downloadClient.GetQueue().ToList();
|
||||
var downloadClientQueue = GetDownloadClient().GetQueue().ToList();
|
||||
var failedItems = downloadClientQueue.Where(q => q.Title.StartsWith("ENCRYPTED / ")).ToList();
|
||||
|
||||
if (!failedItems.Any())
|
||||
@ -96,14 +92,14 @@ private void CheckQueue(List<History.History> grabbedHistory, List<History.Histo
|
||||
if (_configService.RemoveFailedDownloads)
|
||||
{
|
||||
_logger.Info("Removing encrypted download from queue: {0}", failedItem.Title.Replace("ENCRYPTED / ", ""));
|
||||
_downloadClient.RemoveFromQueue(failedItem.Id);
|
||||
GetDownloadClient().RemoveFromQueue(failedItem.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckHistory(List<History.History> grabbedHistory, List<History.History> failedHistory)
|
||||
{
|
||||
var downloadClientHistory = _downloadClient.GetHistory(0, 20).ToList();
|
||||
var downloadClientHistory = GetDownloadClient().GetHistory(0, 20).ToList();
|
||||
var failedItems = downloadClientHistory.Where(h => h.Status == HistoryStatus.Failed).ToList();
|
||||
|
||||
if (!failedItems.Any())
|
||||
@ -135,7 +131,7 @@ private void CheckHistory(List<History.History> grabbedHistory, List<History.His
|
||||
if (_configService.RemoveFailedDownloads)
|
||||
{
|
||||
_logger.Info("Removing failed download from history: {0}", failedItem.Title);
|
||||
_downloadClient.RemoveFromHistory(failedItem.Id);
|
||||
GetDownloadClient().RemoveFromHistory(failedItem.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,6 +158,11 @@ private void PublishDownloadFailedEvent(List<History.History> historyItems, stri
|
||||
});
|
||||
}
|
||||
|
||||
private IDownloadClient GetDownloadClient()
|
||||
{
|
||||
return _downloadClientProvider.GetDownloadClient();
|
||||
}
|
||||
|
||||
public void Execute(FailedDownloadCommand message)
|
||||
{
|
||||
CheckForFailedDownloads();
|
||||
|
Loading…
Reference in New Issue
Block a user