Restrict max strikes to a minimum value (#87)

This commit is contained in:
Flaminel
2025-03-11 23:35:07 +02:00
committed by GitHub
parent a68e13af35
commit e6d3929fc9
3 changed files with 14 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using Common.Exceptions;
using Microsoft.Extensions.Configuration;
namespace Common.Configuration.QueueCleaner;
@@ -39,5 +40,14 @@ public sealed record QueueCleanerConfig : IJobConfig, IIgnoredDownloadsConfig
public void Validate()
{
if (ImportFailedMaxStrikes is > 0 and < 3)
{
throw new ValidationException("the minimum value for IMPORT_FAILED_MAX_STRIKES must be 3");
}
if (StalledMaxStrikes is > 0 and < 3)
{
throw new ValidationException("the minimum value for STALLED_MAX_STRIKES must be 3");
}
}
}

View File

@@ -45,6 +45,7 @@ public sealed class QueueCleaner : GenericHandler
)
{
_config = config.Value;
_config.Validate();
_ignoredDownloadsProvider = ignoredDownloadsProvider;
}

View File

@@ -114,7 +114,7 @@
- Set to `0` to never remove failed imports.
- A strike is given when an item is stalled, stuck in metadata downloading, or failed to be imported.
- Type: Integer
- Possible values: `0` or greater
- Possible values: `0` or a number greater than `2`.
- Default: `0`
- Required: No.
@@ -153,7 +153,7 @@ QUEUECLEANER__IMPORT_FAILED_IGNORE_PATTERNS__1: "manual import required"
- Set to `0` to never remove stalled downloads.
- A strike is given when download speed is 0.
- Type: Integer
- Possible values: `0` or greater
- Possible values: `0` or a number greater than `2`.
- Default: `0`
- Required: No.