Prevent NullRef in naming when truncating a null Release Group

pull/6610/head
Bogdan 8 months ago committed by Mark McDowall
parent 61a7515041
commit 13e29bd257

@ -622,7 +622,7 @@ namespace NzbDrone.Core.Organizer
{
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(episodeFile, useCurrentFilenameAsFallback);
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(episodeFile, useCurrentFilenameAsFallback);
tokenHandlers["{Release Group}"] = m => Truncate(episodeFile.ReleaseGroup, m.CustomFormat) ?? m.DefaultValue("Sonarr");
tokenHandlers["{Release Group}"] = m => episodeFile.ReleaseGroup.IsNullOrWhiteSpace() ? m.DefaultValue("Sonarr") : Truncate(episodeFile.ReleaseGroup, m.CustomFormat);
}
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Series series, EpisodeFile episodeFile)
@ -1168,6 +1168,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