mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-06 06:41:40 +02: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:
parent
c296b6975c
commit
117cebe655
@ -234,69 +234,5 @@ public void Get_Multi_Episode_Zero_Doesnt_Exist_Should_not_add_ignored()
|
|||||||
db.Fetch<Episode>().Should().HaveCount(2);
|
db.Fetch<Episode>().Should().HaveCount(2);
|
||||||
ep.First().Ignored.Should().BeFalse();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -125,14 +125,6 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
|||||||
{
|
{
|
||||||
var result = new List<Episode>();
|
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)
|
foreach (var episodeNumber in parseResult.EpisodeNumbers)
|
||||||
{
|
{
|
||||||
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||||
|
@ -180,7 +180,15 @@ public virtual void ProcessFailedOrUnpackingDownload(DirectoryInfo directoryInfo
|
|||||||
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(8));
|
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(8));
|
||||||
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
|
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);
|
_episodeProvider.SetPostDownloadStatus(episodeIds, postDownloadStatus);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="MiniProfiler" version="1.9" />
|
||||||
<package id="Ninject" version="2.2.1.4" />
|
<package id="Ninject" version="2.2.1.4" />
|
||||||
<package id="SqlServerCompact" version="4.0.8482.1" />
|
<package id="SqlServerCompact" version="4.0.8482.1" />
|
||||||
<package id="MiniProfiler" version="1.9" />
|
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user