mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-11-24 08:42:19 +02:00
Fixed: Validate if equals or child for startup folder
This commit is contained in:
parent
97925feed9
commit
0991cfe27e
@ -10,7 +10,7 @@ public class StartupFolderValidator : PropertyValidator
|
|||||||
|
|
||||||
|
|
||||||
public StartupFolderValidator(IAppFolderInfo appFolderInfo)
|
public StartupFolderValidator(IAppFolderInfo appFolderInfo)
|
||||||
: base("Path cannot be an ancestor of the start up folder")
|
: base("Path cannot be {relationship} the start up folder")
|
||||||
{
|
{
|
||||||
_appFolderInfo = appFolderInfo;
|
_appFolderInfo = appFolderInfo;
|
||||||
}
|
}
|
||||||
@ -19,7 +19,24 @@ protected override bool IsValid(PropertyValidatorContext context)
|
|||||||
{
|
{
|
||||||
if (context.PropertyValue == null) return true;
|
if (context.PropertyValue == null) return true;
|
||||||
|
|
||||||
return !_appFolderInfo.StartUpFolder.IsParentPath(context.PropertyValue.ToString());
|
var startupFolder = _appFolderInfo.StartUpFolder;
|
||||||
|
var folder = context.PropertyValue.ToString();
|
||||||
|
|
||||||
|
if (startupFolder.PathEquals(folder))
|
||||||
|
{
|
||||||
|
context.MessageFormatter.AppendArgument("relationship", "set to");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startupFolder.IsParentPath(folder))
|
||||||
|
{
|
||||||
|
context.MessageFormatter.AppendArgument("relationship", "child of");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user