mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 05:25:10 +00:00
Prevent NullRef in naming when truncating a null Release Group
(cherry picked from commit 13e29bd257ccfccb09e66c940ffabeb6503c05b5)
This commit is contained in:
parent
881fabad93
commit
340ae78f46
1 changed files with 6 additions and 1 deletions
|
@ -380,7 +380,7 @@ private void AddTrackFileTokens(Dictionary<string, Func<TokenMatch, string>> tok
|
||||||
{
|
{
|
||||||
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(trackFile);
|
tokenHandlers["{Original Title}"] = m => GetOriginalTitle(trackFile);
|
||||||
tokenHandlers["{Original Filename}"] = m => GetOriginalFileName(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)
|
private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Artist artist, TrackFile trackFile)
|
||||||
|
@ -739,6 +739,11 @@ private static string CleanFileName(string name, NamingConfig namingConfig)
|
||||||
|
|
||||||
private string Truncate(string input, string formatter)
|
private string Truncate(string input, string formatter)
|
||||||
{
|
{
|
||||||
|
if (input.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
var maxLength = GetMaxLengthFromFormatter(formatter);
|
var maxLength = GetMaxLengthFromFormatter(formatter);
|
||||||
|
|
||||||
if (maxLength == 0 || input.Length <= Math.Abs(maxLength))
|
if (maxLength == 0 || input.Length <= Math.Abs(maxLength))
|
||||||
|
|
Loading…
Reference in a new issue