mirror of
https://github.com/Radarr/Radarr
synced 2024-12-21 23:42:23 +00:00
fixup! New: Deprecate use of movie file tokens in Movie Folder Format
This commit is contained in:
parent
655ebe07a8
commit
5cf3417b8f
1 changed files with 25 additions and 0 deletions
|
@ -23,6 +23,7 @@ public static IRuleBuilderOptions<T, string> ValidMovieFolderFormat<T>(this IRul
|
|||
{
|
||||
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||
ruleBuilder.SetValidator(new IllegalCharactersValidator());
|
||||
ruleBuilder.SetValidator(new IllegalMovieFolderTokensValidator());
|
||||
|
||||
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.MovieTitleRegex)).WithMessage("Must contain movie title");
|
||||
}
|
||||
|
@ -44,6 +45,30 @@ protected override bool IsValid(PropertyValidatorContext context)
|
|||
}
|
||||
}
|
||||
|
||||
public class IllegalMovieFolderTokensValidator : PropertyValidator
|
||||
{
|
||||
protected override string GetDefaultMessageTemplate() => "Must not contain deprecated tokens derived from file properties: {tokens}";
|
||||
|
||||
protected override bool IsValid(PropertyValidatorContext context)
|
||||
{
|
||||
if (context.PropertyValue is not string value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var match = FileNameBuilder.DeprecatedMovieFolderTokensRegex.Matches(value);
|
||||
|
||||
if (match.Any())
|
||||
{
|
||||
context.MessageFormatter.AppendArgument("tokens", string.Join(", ", match.Select(c => c.Value).ToArray()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class IllegalCharactersValidator : PropertyValidator
|
||||
{
|
||||
private static readonly char[] InvalidPathChars = Path.GetInvalidPathChars();
|
||||
|
|
Loading…
Reference in a new issue