From b97e76c8b8ced86f67a436ffaf99285d88796c68 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 5 Jun 2022 20:07:47 -0500 Subject: [PATCH] Fixed: Validate if equals or child for startup folder (cherry picked from commit 0991cfe27efd6ddb533227b25754661e18d7e9ad) --- .../Paths/StartupFolderValidator.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Validation/Paths/StartupFolderValidator.cs b/src/NzbDrone.Core/Validation/Paths/StartupFolderValidator.cs index 158a9ca31..9f097f8d2 100644 --- a/src/NzbDrone.Core/Validation/Paths/StartupFolderValidator.cs +++ b/src/NzbDrone.Core/Validation/Paths/StartupFolderValidator.cs @@ -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; } } }