Fixed: Updating existing import list exclusions

This commit is contained in:
Bogdan 2024-08-12 13:41:42 +03:00
parent 2f04b037a1
commit 7b1bac236f
2 changed files with 12 additions and 3 deletions

View File

@ -20,7 +20,10 @@ namespace Sonarr.Api.V3.ImportLists
{ {
_importListExclusionService = importListExclusionService; _importListExclusionService = importListExclusionService;
SharedValidator.RuleFor(c => c.TvdbId).NotEmpty().SetValidator(importListExclusionExistsValidator); SharedValidator.RuleFor(c => c.TvdbId).Cascade(CascadeMode.Stop)
.NotEmpty()
.SetValidator(importListExclusionExistsValidator);
SharedValidator.RuleFor(c => c.Title).NotEmpty(); SharedValidator.RuleFor(c => c.Title).NotEmpty();
} }

View File

@ -1,6 +1,7 @@
using FluentValidation.Validators; using FluentValidation.Validators;
using NzbDrone.Core.ImportLists.Exclusions;
namespace NzbDrone.Core.ImportLists.Exclusions namespace Sonarr.Api.V3.ImportLists
{ {
public class ImportListExclusionExistsValidator : PropertyValidator public class ImportListExclusionExistsValidator : PropertyValidator
{ {
@ -20,7 +21,12 @@ namespace NzbDrone.Core.ImportLists.Exclusions
return true; return true;
} }
return !_importListExclusionService.All().Exists(s => s.TvdbId == (int)context.PropertyValue); if (context.InstanceToValidate is not ImportListExclusionResource listExclusionResource)
{
return true;
}
return !_importListExclusionService.All().Exists(v => v.TvdbId == (int)context.PropertyValue && v.Id != listExclusionResource.Id);
} }
} }
} }