mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 01:42:35 +01:00
Prevent NullRef in naming when truncating a null Release Group
(cherry picked from commit 13e29bd257ccfccb09e66c940ffabeb6503c05b5)
This commit is contained in:
parent
d7b9b2ccb2
commit
41ff9352b9
@ -327,7 +327,7 @@ private void AddMovieFileTokens(Dictionary<string, Func<TokenMatch, string>> tok
|
||||
{
|
||||
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(movieFile, multipleTokens);
|
||||
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(movieFile, multipleTokens);
|
||||
tokenHandlers["{Release Group}"] = m => Truncate(movieFile.ReleaseGroup, m.CustomFormat) ?? m.DefaultValue("Radarr");
|
||||
tokenHandlers["{Release Group}"] = m => movieFile.ReleaseGroup.IsNullOrWhiteSpace() ? m.DefaultValue("Radarr") : Truncate(movieFile.ReleaseGroup, m.CustomFormat);
|
||||
}
|
||||
|
||||
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Movie movie, MovieFile movieFile)
|
||||
@ -621,6 +621,11 @@ private string ReplaceReservedDeviceNames(string input)
|
||||
|
||||
private string Truncate(string input, string formatter)
|
||||
{
|
||||
if (input.IsNullOrWhiteSpace())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var maxLength = GetMaxLengthFromFormatter(formatter);
|
||||
|
||||
if (maxLength == 0 || input.Length <= Math.Abs(maxLength))
|
||||
|
Loading…
Reference in New Issue
Block a user