mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2025-12-23 22:18:39 -05:00
Remove empty clean categories list validation (#131)
This commit is contained in:
@@ -33,11 +33,6 @@ public sealed record DownloadCleanerConfig : IJobConfig, IIgnoredDownloadsConfig
|
||||
return;
|
||||
}
|
||||
|
||||
if (Categories?.Count is null or 0)
|
||||
{
|
||||
throw new ValidationException("no categories configured");
|
||||
}
|
||||
|
||||
if (Categories?.GroupBy(x => x.Name).Any(x => x.Count() > 1) is true)
|
||||
{
|
||||
throw new ValidationException("duplicated clean categories found");
|
||||
|
||||
@@ -58,9 +58,12 @@ public sealed class DownloadCleaner : GenericHandler
|
||||
return;
|
||||
}
|
||||
|
||||
if (_config.Categories?.Count is null or 0)
|
||||
bool isUnlinkedEnabled = !string.IsNullOrEmpty(_config.UnlinkedTargetCategory) && _config.UnlinkedCategories?.Count > 0;
|
||||
bool isCleaningEnabled = _config.Categories?.Count > 0;
|
||||
|
||||
if (!isUnlinkedEnabled && !isCleaningEnabled)
|
||||
{
|
||||
_logger.LogWarning("no categories configured");
|
||||
_logger.LogWarning("{name} is not configured properly", nameof(DownloadCleaner));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,9 +71,18 @@ public sealed class DownloadCleaner : GenericHandler
|
||||
|
||||
await _downloadService.LoginAsync();
|
||||
List<object>? downloads = await _downloadService.GetSeedingDownloads();
|
||||
List<object>? downloadsToChangeCategory = null;
|
||||
|
||||
if (downloads?.Count is null or 0)
|
||||
{
|
||||
_logger.LogDebug("no seeding downloads found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_config.UnlinkedTargetCategory) && _config.UnlinkedCategories?.Count > 0)
|
||||
_logger.LogTrace("found {count} seeding downloads", downloads.Count);
|
||||
|
||||
List<object>? downloadsToChangeCategory = null;
|
||||
|
||||
if (isUnlinkedEnabled)
|
||||
{
|
||||
if (!_hardLinkCategoryCreated)
|
||||
{
|
||||
@@ -89,17 +101,27 @@ public sealed class DownloadCleaner : GenericHandler
|
||||
await ProcessArrConfigAsync(_sonarrConfig, InstanceType.Sonarr, true);
|
||||
await ProcessArrConfigAsync(_radarrConfig, InstanceType.Radarr, true);
|
||||
await ProcessArrConfigAsync(_lidarrConfig, InstanceType.Lidarr, true);
|
||||
|
||||
if (isUnlinkedEnabled)
|
||||
{
|
||||
_logger.LogTrace("found {count} potential downloads to change category", downloadsToChangeCategory?.Count);
|
||||
await _downloadService.ChangeCategoryForNoHardLinksAsync(downloadsToChangeCategory, _excludedHashes, ignoredDownloads);
|
||||
_logger.LogTrace("finished changing category");
|
||||
}
|
||||
|
||||
_logger.LogTrace("looking for downloads to change category");
|
||||
await _downloadService.ChangeCategoryForNoHardLinksAsync(downloadsToChangeCategory, _excludedHashes, ignoredDownloads);
|
||||
if (_config.Categories?.Count is null or 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<object>? downloadsToClean = _downloadService.FilterDownloadsToBeCleanedAsync(downloads, _config.Categories);
|
||||
|
||||
// release unused objects
|
||||
downloads = null;
|
||||
|
||||
_logger.LogTrace("looking for downloads to clean");
|
||||
|
||||
_logger.LogTrace("found {count} potential downloads to clean", downloadsToClean?.Count);
|
||||
await _downloadService.CleanDownloadsAsync(downloadsToClean, _config.Categories, _excludedHashes, ignoredDownloads);
|
||||
_logger.LogTrace("finished cleaning downloads");
|
||||
}
|
||||
|
||||
protected override async Task ProcessInstanceAsync(ArrInstance instance, InstanceType instanceType)
|
||||
|
||||
@@ -12,8 +12,12 @@ services:
|
||||
image: ghcr.io/flmorg/cleanuperr:latest
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
# if you want persistent logs
|
||||
- ./cleanuperr/logs:/var/logs
|
||||
# if you want to ignore certain downloads from being processed
|
||||
- ./cleanuperr/ignored.txt:/ignored.txt
|
||||
# if you're using cross-seed and the hardlinks functionality
|
||||
- ./downloads:/downloads
|
||||
environment:
|
||||
# general settings
|
||||
- TZ=America/New_York
|
||||
|
||||
@@ -30,11 +30,17 @@ const settings: EnvVarProps[] = [
|
||||
title: "Multiple patterns can be specified using incrementing numbers starting from 0.",
|
||||
content: `DOWNLOADCLEANER__UNLINKED_CATEGORIES__0=tv-sonarr
|
||||
DOWNLOADCLEANER__UNLINKED_CATEGORIES__1=radarr`
|
||||
}
|
||||
},
|
||||
],
|
||||
type: "text",
|
||||
defaultValue: "Empty",
|
||||
required: false,
|
||||
notes: [
|
||||
"The category name must match the category that was set in the *arr.",
|
||||
"For qBittorrent, the category name is the name of the download category.",
|
||||
"For Deluge, the category name is the name of the label.",
|
||||
"For Transmission, the category name is the last directory from the save location.",
|
||||
],
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user