mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-01 09:31:33 +02:00
Prevent NullRef in naming when truncating a null Release Group
This commit is contained in:
parent
61a7515041
commit
13e29bd257
1 changed files with 6 additions and 1 deletions
|
|
@ -622,7 +622,7 @@ private void AddEpisodeFileTokens(Dictionary<string, Func<TokenMatch, string>> t
|
|||
{
|
||||
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 @@ private static string CleanFileName(string name, NamingConfig namingConfig)
|
|||
|
||||
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 a new issue