Fixed: Prevent root folders from being added under the startup folder

This commit is contained in:
Mark McDowall
2016-03-25 19:03:28 -07:00
parent 9c91f11cdc
commit d37343bb7d
3 changed files with 29 additions and 1 deletions
@@ -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());
}
}
}