Prevent NullRef in naming when truncating a null Release Group

(cherry picked from commit 13e29bd257ccfccb09e66c940ffabeb6503c05b5)
pull/4653/head
Bogdan 9 months ago
parent 881fabad93
commit 340ae78f46

@ -380,7 +380,7 @@ namespace NzbDrone.Core.Organizer
{
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(trackFile);
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(trackFile);
tokenHandlers["{Release Group}"] = m => Truncate(trackFile.ReleaseGroup, m.CustomFormat) ?? m.DefaultValue("Lidarr");
tokenHandlers["{Release Group}"] = m => trackFile.ReleaseGroup.IsNullOrWhiteSpace() ? m.DefaultValue("Lidarr") : Truncate(trackFile.ReleaseGroup, m.CustomFormat);
}
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Artist artist, TrackFile trackFile)
@ -739,6 +739,11 @@ namespace NzbDrone.Core.Organizer
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…
Cancel
Save