mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 11:13:22 +01:00
Fixed: Enforce validation warnings
(cherry picked from commit 48ee1158ad4213fd0690842e2672f52d08f7ad26) Closes #2570
This commit is contained in:
parent
1db333088a
commit
257d279e43
3 changed files with 6 additions and 13 deletions
|
|
@ -32,9 +32,9 @@ function createSaveProviderHandler(section, url, options = {}, removeStale = fal
|
|||
const params = { ...queryParams };
|
||||
|
||||
// If the user is re-saving the same provider without changes
|
||||
// force it to be saved. Only applies to editing existing providers.
|
||||
// force it to be saved.
|
||||
|
||||
if (id && _.isEqual(saveData, lastSaveData)) {
|
||||
if (_.isEqual(saveData, lastSaveData)) {
|
||||
params.forceSave = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@ public SeedCriteriaSettingsValidator(double seedRatioMinimum = 0.0, int seedTime
|
|||
|
||||
public class SeedCriteriaSettings
|
||||
{
|
||||
private static readonly SeedCriteriaSettingsValidator Validator = new SeedCriteriaSettingsValidator();
|
||||
|
||||
[FieldDefinition(0, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default. Ratio should be at least 1.0 and follow the indexers rules")]
|
||||
public double? SeedRatio { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public List<TProviderResource> GetAll()
|
|||
}
|
||||
|
||||
[RestPostById]
|
||||
public ActionResult<TProviderResource> CreateProvider(TProviderResource providerResource)
|
||||
public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);
|
||||
|
||||
if (providerDefinition.Enable)
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ public ActionResult<TProviderResource> CreateProvider(TProviderResource provider
|
|||
[RestPutById]
|
||||
public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);
|
||||
|
||||
// Only test existing definitions if it is enabled and forceSave isn't set.
|
||||
if (providerDefinition.Enable && !forceSave)
|
||||
|
|
@ -191,12 +191,7 @@ protected virtual void Test(TProviderDefinition definition, bool includeWarnings
|
|||
|
||||
protected void VerifyValidationResult(ValidationResult validationResult, bool includeWarnings)
|
||||
{
|
||||
var result = validationResult as NzbDroneValidationResult;
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = new NzbDroneValidationResult(validationResult.Errors);
|
||||
}
|
||||
var result = validationResult as NzbDroneValidationResult ?? new NzbDroneValidationResult(validationResult.Errors);
|
||||
|
||||
if (includeWarnings && (!result.IsValid || result.HasWarnings))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue