mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 05:25:10 +00:00
parent
8ff8c27e24
commit
f49388f3c4
2 changed files with 6 additions and 1 deletions
|
@ -63,6 +63,7 @@ public ArtistController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
SystemFolderValidator systemFolderValidator,
|
SystemFolderValidator systemFolderValidator,
|
||||||
QualityProfileExistsValidator qualityProfileExistsValidator,
|
QualityProfileExistsValidator qualityProfileExistsValidator,
|
||||||
MetadataProfileExistsValidator metadataProfileExistsValidator,
|
MetadataProfileExistsValidator metadataProfileExistsValidator,
|
||||||
|
RootFolderExistsValidator rootFolderExistsValidator,
|
||||||
ArtistFolderAsRootFolderValidator artistFolderAsRootFolderValidator)
|
ArtistFolderAsRootFolderValidator artistFolderAsRootFolderValidator)
|
||||||
: base(signalRBroadcaster)
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +96,7 @@ public ArtistController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
|
PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
|
||||||
PostValidator.RuleFor(s => s.RootFolderPath)
|
PostValidator.RuleFor(s => s.RootFolderPath)
|
||||||
.IsValidPath()
|
.IsValidPath()
|
||||||
|
.SetValidator(rootFolderExistsValidator)
|
||||||
.SetValidator(artistFolderAsRootFolderValidator)
|
.SetValidator(artistFolderAsRootFolderValidator)
|
||||||
.When(s => s.Path.IsNullOrWhiteSpace());
|
.When(s => s.Path.IsNullOrWhiteSpace());
|
||||||
PostValidator.RuleFor(s => s.ArtistName).NotEmpty();
|
PostValidator.RuleFor(s => s.ArtistName).NotEmpty();
|
||||||
|
@ -154,6 +156,7 @@ public List<ArtistResource> AllArtists(Guid? mbId)
|
||||||
|
|
||||||
[RestPostById]
|
[RestPostById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
|
[Produces("application/json")]
|
||||||
public ActionResult<ArtistResource> AddArtist(ArtistResource artistResource)
|
public ActionResult<ArtistResource> AddArtist(ArtistResource artistResource)
|
||||||
{
|
{
|
||||||
var artist = _addArtistService.AddArtist(artistResource.ToModel());
|
var artist = _addArtistService.AddArtist(artistResource.ToModel());
|
||||||
|
@ -163,6 +166,7 @@ public ActionResult<ArtistResource> AddArtist(ArtistResource artistResource)
|
||||||
|
|
||||||
[RestPutById]
|
[RestPutById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
|
[Produces("application/json")]
|
||||||
public ActionResult<ArtistResource> UpdateArtist(ArtistResource artistResource, bool moveFiles = false)
|
public ActionResult<ArtistResource> UpdateArtist(ArtistResource artistResource, bool moveFiles = false)
|
||||||
{
|
{
|
||||||
var artist = _artistService.GetArtist(artistResource.Id);
|
var artist = _artistService.GetArtist(artistResource.Id);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FluentValidation.Validators;
|
using FluentValidation.Validators;
|
||||||
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ protected override bool IsValid(PropertyValidatorContext context)
|
||||||
{
|
{
|
||||||
context.MessageFormatter.AppendArgument("path", context.PropertyValue?.ToString());
|
context.MessageFormatter.AppendArgument("path", context.PropertyValue?.ToString());
|
||||||
|
|
||||||
return context.PropertyValue == null || _rootFolderService.All().Exists(r => r.Path.PathEquals(context.PropertyValue.ToString()));
|
return context.PropertyValue == null || _rootFolderService.All().Exists(r => r.Path.IsPathValid(PathValidationType.CurrentOs) && r.Path.PathEquals(context.PropertyValue.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue