mirror of
https://github.com/Readarr/Readarr
synced 2026-01-03 22:28:23 +01:00
Fixed: Validate if equals or child for startup folder
Fixes #1712 Close #1713 (cherry picked from commit 0991cfe27efd6ddb533227b25754661e18d7e9ad)
This commit is contained in:
parent
d93a0c27e9
commit
b016b36435
1 changed files with 19 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ public class StartupFolderValidator : PropertyValidator
|
|||
private readonly 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;
|
||||
}
|
||||
|
|
@ -21,7 +21,24 @@ protected override bool IsValid(PropertyValidatorContext context)
|
|||
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 a new issue