mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-27 15:18:50 -05:00
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using Common.Exceptions;
|
|
|
|
namespace Common.Configuration.DownloadCleaner;
|
|
|
|
public sealed record CleanCategory : IConfig
|
|
{
|
|
public required string Name { get; init; }
|
|
|
|
/// <summary>
|
|
/// Max ratio before removing a download.
|
|
/// </summary>
|
|
public required double MaxRatio { get; init; } = -1;
|
|
|
|
/// <summary>
|
|
/// Min number of hours to seed before removing a download, if the ratio has been met.
|
|
/// </summary>
|
|
public required double MinSeedTime { get; init; }
|
|
|
|
/// <summary>
|
|
/// Number of hours to seed before removing a download.
|
|
/// </summary>
|
|
public required double MaxSeedTime { get; init; } = -1;
|
|
|
|
public void Validate()
|
|
{
|
|
if (string.IsNullOrEmpty(Name.Trim()))
|
|
{
|
|
throw new ValidationException("Category name can not be empty");
|
|
}
|
|
|
|
if (MaxRatio < 0 && MaxSeedTime < 0)
|
|
{
|
|
throw new ValidationException("Both max ratio and max seed time are disabled");
|
|
}
|
|
|
|
if (MinSeedTime < 0)
|
|
{
|
|
throw new ValidationException("Min seed time can not be negative");
|
|
}
|
|
}
|
|
} |