mirror of https://github.com/lidarr/Lidarr
Fixed: Prevent root folders from being added under the startup folder
This commit is contained in:
parent
9c91f11cdc
commit
d37343bb7d
|
@ -16,7 +16,8 @@ namespace NzbDrone.Api.RootFolders
|
|||
RootFolderValidator rootFolderValidator,
|
||||
PathExistsValidator pathExistsValidator,
|
||||
DroneFactoryValidator droneFactoryValidator,
|
||||
MappedNetworkDriveValidator mappedNetworkDriveValidator)
|
||||
MappedNetworkDriveValidator mappedNetworkDriveValidator,
|
||||
StartupFolderValidator startupFolderValidator)
|
||||
: base(signalRBroadcaster)
|
||||
{
|
||||
_rootFolderService = rootFolderService;
|
||||
|
@ -32,6 +33,7 @@ namespace NzbDrone.Api.RootFolders
|
|||
.SetValidator(rootFolderValidator)
|
||||
.SetValidator(droneFactoryValidator)
|
||||
.SetValidator(mappedNetworkDriveValidator)
|
||||
.SetValidator(startupFolderValidator)
|
||||
.SetValidator(pathExistsValidator);
|
||||
}
|
||||
|
||||
|
|
|
@ -1032,6 +1032,7 @@
|
|||
<Compile Include="Validation\Paths\DroneFactoryValidator.cs" />
|
||||
<Compile Include="Validation\Paths\PathExistsValidator.cs" />
|
||||
<Compile Include="Validation\Paths\PathValidator.cs" />
|
||||
<Compile Include="Validation\Paths\StartupFolderValidator.cs" />
|
||||
<Compile Include="Validation\Paths\RootFolderValidator.cs" />
|
||||
<Compile Include="Validation\Paths\SeriesAncestorValidator.cs" />
|
||||
<Compile Include="Validation\Paths\SeriesExistsValidator.cs" />
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
using FluentValidation.Validators;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Validation.Paths
|
||||
{
|
||||
public class StartupFolderValidator : PropertyValidator
|
||||
{
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
|
||||
|
||||
public StartupFolderValidator(IAppFolderInfo appFolderInfo)
|
||||
: base("Path cannot be an ancestor of the start up folder")
|
||||
{
|
||||
_appFolderInfo = appFolderInfo;
|
||||
}
|
||||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
if (context.PropertyValue == null) return true;
|
||||
|
||||
return !_appFolderInfo.StartUpFolder.IsParentPath(context.PropertyValue.ToString());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue