added category change for downloads with no additional hardlinks
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Common.Configuration.DownloadCleaner;
|
||||
|
||||
public sealed record Category : IConfig
|
||||
public sealed record CleanCategory : IConfig
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
|
||||
@@ -8,11 +8,17 @@ public sealed record DownloadCleanerConfig : IJobConfig
|
||||
public const string SectionName = "DownloadCleaner";
|
||||
|
||||
public bool Enabled { get; init; }
|
||||
|
||||
public List<Category>? Categories { get; init; }
|
||||
|
||||
public List<CleanCategory>? Categories { get; init; }
|
||||
|
||||
[ConfigurationKeyName("DELETE_PRIVATE")]
|
||||
public bool DeletePrivate { get; set; }
|
||||
public bool DeletePrivate { get; init; }
|
||||
|
||||
[ConfigurationKeyName("NO_HARDLINKS_CATEGORY")]
|
||||
public string NoHardlinksCategory { get; init; } = "";
|
||||
|
||||
[ConfigurationKeyName("HARDLINK_CATEGORIES")]
|
||||
public List<string>? HardlinkCategories { get; init; }
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
@@ -32,5 +38,25 @@ public sealed record DownloadCleanerConfig : IJobConfig
|
||||
}
|
||||
|
||||
Categories?.ForEach(x => x.Validate());
|
||||
|
||||
if (string.IsNullOrEmpty(NoHardlinksCategory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (HardlinkCategories?.Count is null or 0)
|
||||
{
|
||||
throw new ValidationException("no categories configured");
|
||||
}
|
||||
|
||||
if (HardlinkCategories.Contains(NoHardlinksCategory))
|
||||
{
|
||||
throw new ValidationException("NO_HARDLINKS_CATEGORY is present in the list of filtered categories");
|
||||
}
|
||||
|
||||
if (HardlinkCategories.Any(string.IsNullOrEmpty))
|
||||
{
|
||||
throw new ValidationException("empty hardlink filter category found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,16 @@ public abstract record NotificationConfig
|
||||
|
||||
[ConfigurationKeyName("ON_DOWNLOAD_CLEANED")]
|
||||
public bool OnDownloadCleaned { get; init; }
|
||||
|
||||
[ConfigurationKeyName("ON_CATEGORY_CHANGED")]
|
||||
public bool OnCategoryChanged { get; init; }
|
||||
|
||||
public bool IsEnabled => OnImportFailedStrike || OnStalledStrike || OnQueueItemDeleted || OnDownloadCleaned;
|
||||
public bool IsEnabled =>
|
||||
OnImportFailedStrike ||
|
||||
OnStalledStrike ||
|
||||
OnQueueItemDeleted ||
|
||||
OnDownloadCleaned ||
|
||||
OnCategoryChanged;
|
||||
|
||||
public abstract bool IsValid();
|
||||
}
|
||||
Reference in New Issue
Block a user