diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs index 2f0aaddc8..f4da13b5b 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/EpisodeTitleCollapseFixture.cs @@ -97,5 +97,17 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) .Should().Be("South Park - S15E06-E07 - Hello + World"); } + + [Test] + public void should_not_collaspe_when_result_is_empty() + { + _namingConfig.StandardEpisodeFormat = "{Episode Title}"; + + _episode1.Title = "Part 1"; + _episode2.Title = "Part 2"; + + Subject.BuildFileName(new List { _episode1, _episode2 }, _series, _episodeFile) + .Should().Be("Part 1 + Part 2"); + } } } diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index c0be11773..46d92348a 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -684,10 +684,17 @@ namespace NzbDrone.Core.Organizer return episodes.First().Title.TrimEnd(EpisodeTitleTrimCharacters); } - var titles = episodes - .Select(c => c.Title.TrimEnd(EpisodeTitleTrimCharacters)) - .Select(CleanupEpisodeTitle) - .Distinct(); + var titles = episodes.Select(c => c.Title.TrimEnd(EpisodeTitleTrimCharacters)) + .Select(CleanupEpisodeTitle) + .Distinct() + .ToList(); + + if (titles.All(t => t.IsNullOrWhiteSpace())) + { + titles = episodes.Select(c => c.Title.TrimEnd(EpisodeTitleTrimCharacters)) + .Distinct() + .ToList(); + } return string.Join(separator, titles); }