Fixed: Season mismatch between file and folder not rejecting import

pull/3061/head
devbrian 5 years ago committed by Mark McDowall
parent 9b0c945086
commit e6c34f4311

@ -134,6 +134,35 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse(); Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
} }
[Test]
public void should_be_rejected_if_file_and_folder_do_not_have_episodes_from_the_same_partial_season()
{
_localEpisode.FileEpisodeInfo.SeasonNumber = 2;
_localEpisode.FileEpisodeInfo.EpisodeNumbers = new[] { 1 };
_localEpisode.FolderEpisodeInfo.SeasonNumber = 1;
_localEpisode.FolderEpisodeInfo.EpisodeNumbers = new[] { 1, 2 };
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01.720p.HDTV-Sonarr\S02E01.mkv".AsOsAgnostic();
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeFalse();
}
[Test]
public void should_be_accepted_if_file_and_folder_have_episodes_from_the_same_season()
{
_localEpisode.FileEpisodeInfo.SeasonNumber = 1;
_localEpisode.FileEpisodeInfo.EpisodeNumbers = new[] { 1 };
_localEpisode.FolderEpisodeInfo.FullSeason = true;
_localEpisode.FolderEpisodeInfo.SeasonNumber = 1;
_localEpisode.FolderEpisodeInfo.EpisodeNumbers = new[] { 1, 2 };
_localEpisode.Path = @"C:\Test\Unsorted\Series.Title.S01.720p.HDTV-Sonarr\S01E01.mkv".AsOsAgnostic();
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
}
[Test] [Test]
public void should_be_accepted_if_both_file_and_folder_info_map_to_same_special() public void should_be_accepted_if_both_file_and_folder_info_map_to_same_special()
{ {

@ -48,6 +48,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
_logger.Debug("No file ParsedEpisodeInfo, skipping check"); _logger.Debug("No file ParsedEpisodeInfo, skipping check");
return Decision.Accept(); return Decision.Accept();
} }
if (folderInfo.SeasonNumber != fileInfo.SeasonNumber)
{
return Decision.Reject("Season number {0} was unexpected considering the folder name {1}", fileInfo.SeasonNumber, folderInfo.ReleaseTitle);
}
if (!folderInfo.EpisodeNumbers.Any()) if (!folderInfo.EpisodeNumbers.Any())
{ {
@ -55,11 +60,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
return Decision.Accept(); return Decision.Accept();
} }
if (folderInfo.SeasonNumber != fileInfo.SeasonNumber)
{
return Decision.Reject("Season number {0} was unexpected considering the folder name {1}", fileInfo.SeasonNumber, folderInfo.ReleaseTitle);
}
var unexpected = fileInfo.EpisodeNumbers.Where(f => !folderInfo.EpisodeNumbers.Contains(f)).ToList(); var unexpected = fileInfo.EpisodeNumbers.Where(f => !folderInfo.EpisodeNumbers.Contains(f)).ToList();
if (unexpected.Any()) if (unexpected.Any())

Loading…
Cancel
Save