mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-06-10 14:55:34 -04:00
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using ValidationException = Common.Exceptions.ValidationException;
|
|
|
|
namespace Common.Configuration.DownloadCleaner;
|
|
|
|
public sealed record CleanCategory : IConfig
|
|
{
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public Guid Id { get; init; } = Guid.NewGuid();
|
|
|
|
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");
|
|
}
|
|
}
|
|
} |