streamlined downloads processing after category changed
This commit is contained in:
@@ -61,31 +61,20 @@ public sealed class DownloadCleaner : GenericHandler
|
||||
}
|
||||
|
||||
await _downloadService.LoginAsync();
|
||||
|
||||
List<object>? downloadsToBeCleaned = await _downloadService.GetDownloadsToBeCleanedAsync(_config.Categories);
|
||||
List<object>? downloads = await _downloadService.GetSeedingDownloads();
|
||||
List<object>? downloadsToChangeCategory = null;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(_config.NoHardLinksCategory) && _config.NoHardLinksCategories?.Count > 0)
|
||||
{
|
||||
if (!_hardLinkCategoryCreated)
|
||||
{
|
||||
_logger.LogTrace("creating category {cat}", _config.NoHardLinksCategory);
|
||||
|
||||
_logger.LogDebug("creating category {cat}", _config.NoHardLinksCategory);
|
||||
|
||||
await _downloadService.CreateCategoryAsync(_config.NoHardLinksCategory);
|
||||
_hardLinkCategoryCreated = true;
|
||||
}
|
||||
|
||||
_logger.LogTrace("getting downloads to change category");
|
||||
downloadsToChangeCategory = await _downloadService.GetDownloadsToChangeCategoryAsync(_config.NoHardLinksCategories);
|
||||
}
|
||||
|
||||
bool hasDownloadsToClean = downloadsToBeCleaned?.Count > 0;
|
||||
bool hasDownloadsToChange = downloadsToChangeCategory?.Count > 0;
|
||||
|
||||
if (!hasDownloadsToClean && !hasDownloadsToChange)
|
||||
{
|
||||
_logger.LogDebug("no downloads to process");
|
||||
return;
|
||||
_downloadService.FilterDownloadsToChangeCategoryAsync(downloads, _config.NoHardLinksCategories);
|
||||
}
|
||||
|
||||
// wait for the downloads to appear in the arr queue
|
||||
@@ -95,25 +84,13 @@ public sealed class DownloadCleaner : GenericHandler
|
||||
await ProcessArrConfigAsync(_radarrConfig, InstanceType.Radarr, true);
|
||||
await ProcessArrConfigAsync(_lidarrConfig, InstanceType.Lidarr, true);
|
||||
|
||||
if (hasDownloadsToChange)
|
||||
{
|
||||
_logger.LogTrace("processing downloads to change category");
|
||||
await _downloadService.ChangeCategoryForNoHardLinksAsync(downloadsToChangeCategory, _excludedHashes);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogTrace("no downloads found to change category");
|
||||
}
|
||||
_logger.LogTrace("looking for downloads to change category");
|
||||
await _downloadService.ChangeCategoryForNoHardLinksAsync(downloadsToChangeCategory, _excludedHashes);
|
||||
|
||||
if (hasDownloadsToClean)
|
||||
{
|
||||
_logger.LogTrace("processing downloads to be cleaned");
|
||||
await _downloadService.CleanDownloadsAsync(downloadsToBeCleaned, _config.Categories, _excludedHashes);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogTrace("no downloads found to be cleaned");
|
||||
}
|
||||
List<object>? downloadsToClean = _downloadService.FilterDownloadsToBeCleanedAsync(downloads, _config.Categories);
|
||||
|
||||
_logger.LogTrace("looking for downloads clean");
|
||||
await _downloadService.CleanDownloadsAsync(downloadsToClean, _config.Categories, _excludedHashes);
|
||||
}
|
||||
|
||||
protected override async Task ProcessInstanceAsync(ArrInstance instance, InstanceType instanceType)
|
||||
|
||||
Reference in New Issue
Block a user