1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-27 18:17:13 +00:00

Found and fixed a bug in EpisodeProvider.GetEpisodesByParseResults, where it would incorrectly return all episodes for a season when a file was detected as a Full Season release.

This commit is contained in:
Mark McDowall 2011-10-15 11:51:11 -07:00
parent c296b6975c
commit 117cebe655
4 changed files with 10 additions and 74 deletions

View file

@ -234,69 +234,5 @@ public void Get_Multi_Episode_Zero_Doesnt_Exist_Should_not_add_ignored()
db.Fetch<Episode>().Should().HaveCount(2);
ep.First().Ignored.Should().BeFalse();
}
[Test]
public void Full_Season_return_all_episodes_for_season()
{
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.SeasonNumber = 2)
.Build();
db.Insert(fakeSeries);
db.InsertMany(fakeEpisodes);
var parseResult = new EpisodeParseResult
{
Series = fakeSeries,
SeasonNumber = 2,
EpisodeNumbers = new List<int>(),
FullSeason = true
};
var ep = mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(parseResult);
ep.Should().HaveCount(10);
db.Fetch<Episode>().Should().HaveCount(10);
}
[Test]
public void No_Episodes_Not_a_proper_full_season_release()
{
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.SeasonNumber = 2)
.Build();
db.Insert(fakeSeries);
db.InsertMany(fakeEpisodes);
var parseResult = new EpisodeParseResult
{
Series = fakeSeries,
SeasonNumber = 2,
EpisodeNumbers = new List<int>(),
FullSeason = false
};
var ep = mocker.Resolve<EpisodeProvider>().GetEpisodesByParseResult(parseResult);
ep.Should().HaveCount(0);
db.Fetch<Episode>().Should().HaveCount(10);
}
}
}

View file

@ -125,14 +125,6 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
{
var result = new List<Episode>();
if (parseResult.EpisodeNumbers.Count == 0 && parseResult.FullSeason)
{
result.AddRange(GetEpisodesBySeason(parseResult.Series.SeriesId, parseResult.SeasonNumber));
//Return now as no further processing is required
return result;
}
foreach (var episodeNumber in parseResult.EpisodeNumbers)
{
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);

View file

@ -180,7 +180,15 @@ public virtual void ProcessFailedOrUnpackingDownload(DirectoryInfo directoryInfo
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(8));
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
var episodeIds = _episodeProvider.GetEpisodesByParseResult(parseResult).Select(e => e.EpisodeId);
var episodeIds = new List<int>();
if (parseResult.EpisodeNumbers.Count == 0 && parseResult.FullSeason)
episodeIds =
_episodeProvider.GetEpisodesBySeason(parseResult.Series.SeriesId, parseResult.SeasonNumber)
.Select(e => e.EpisodeId).ToList();
else
episodeIds = _episodeProvider.GetEpisodesByParseResult(parseResult).Select(e => e.EpisodeId).ToList();
_episodeProvider.SetPostDownloadStatus(episodeIds, postDownloadStatus);
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MiniProfiler" version="1.9" />
<package id="Ninject" version="2.2.1.4" />
<package id="SqlServerCompact" version="4.0.8482.1" />
<package id="MiniProfiler" version="1.9" />
</packages>