Fixed issues that came up after making changes to Episode and EpisodeFile.

This commit is contained in:
markus101 2011-02-22 00:13:16 -08:00
parent 738700537e
commit 891acfff44
5 changed files with 38 additions and 37 deletions

View File

@ -51,10 +51,9 @@ namespace NzbDrone.Core.Test
HistoryId = new int(),
Date = DateTime.Now,
IsProper = false,
Quality = 1,
Indexer = indexer,
Episode = episode,
EpisodeId = 1234
Quality = QualityTypes.TV,
IndexerName = indexer.IndexerName,
EpisodeId = episode.EpisodeId
});
var repo = new Mock<IRepository>();
@ -105,10 +104,9 @@ namespace NzbDrone.Core.Test
HistoryId = new int(),
Date = DateTime.Now,
IsProper = false,
Quality = 1,
Indexer = indexer,
Episode = episode,
EpisodeId = 1234
Quality = QualityTypes.TV,
IndexerName = indexer.IndexerName,
EpisodeId = episode.EpisodeId
});
var proper = false;
@ -162,10 +160,9 @@ namespace NzbDrone.Core.Test
HistoryId = new int(),
Date = DateTime.Now,
IsProper = false,
Quality = 1,
Indexer = indexer,
Episode = episode,
EpisodeId = 1234
Quality = QualityTypes.TV,
IndexerName = indexer.IndexerName,
EpisodeId = episode.EpisodeId
});
var repo = new Mock<IRepository>();

View File

@ -66,7 +66,7 @@ namespace NzbDrone.Core.Test
Assert.IsNotNull(result);
repository.Verify(r => r.Add<EpisodeFile>(result), Times.Once());
Assert.AreEqual(fakeEpisode.EpisodeId, result.EpisodeId);
Assert.AreEqual(fakeEpisode, result.Episodes[0]);
Assert.AreEqual(fakeEpisode.SeriesId, result.SeriesId);
Assert.AreEqual(QualityTypes.DVD, result.Quality);
Assert.AreEqual(Parser.NormalizePath(fileName), result.Path);

View File

@ -164,6 +164,8 @@
<Compile Include="Instrumentation\NlogWriter.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeModel.cs" />
<Compile Include="Model\EpisodeRenameModel.cs" />
<Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Model\FeedInfoModel.cs" />
<Compile Include="Model\NzbInfoModel.cs" />
<Compile Include="Model\NzbSiteModel.cs" />
@ -173,10 +175,12 @@
<Compile Include="Providers\IIndexerProvider.cs" />
<Compile Include="Providers\IndexerProvider.cs" />
<Compile Include="Providers\IQualityProvider.cs" />
<Compile Include="Providers\IRenameProvider.cs" />
<Compile Include="Providers\IRssSyncProvider.cs" />
<Compile Include="Providers\IRssProvider.cs" />
<Compile Include="Providers\ITimerProvider.cs" />
<Compile Include="Providers\QualityProvider.cs" />
<Compile Include="Providers\RenameProvider.cs" />
<Compile Include="Providers\RssSyncProvider.cs" />
<Compile Include="Providers\RssProvider.cs" />
<Compile Include="Providers\TimerProvider.cs" />

View File

@ -94,37 +94,34 @@ namespace NzbDrone.Core.Providers
episode.EpisodeId = dbEpisode.EpisodeId;
var epWithFiles = _sonicRepo.All<EpisodeFile>().Where(c => c.EpisodeId == episode.EpisodeId);
var file = _sonicRepo.Single<EpisodeFile>(c => c.FileId == dbEpisode.FileId);
if (epWithFiles != null)
if (file != null)
{
//If not null we need to see if this episode has the quality as the download (or if it is better)
foreach (var file in epWithFiles)
if (file.Quality == episode.Quality)
{
if (file.Quality == episode.Quality)
//If the episodeFile is a Proper we don't need to download again
if (file.Proper)
return false;
}
//There will never be a time when the episode quality is less than what we have and we want it... ever.... I think.
if (file.Quality > episode.Quality)
return false;
//Now we need to handle upgrades and actually pay attention to the Cutoff Value
if (file.Quality < episode.Quality)
{
var series = _series.GetSeries(episode.SeriesId);
var quality = _quality.Find(series.QualityProfileId);
if (quality.Cutoff <= file.Quality)
{
//If the episodeFile is a Proper we don't need to download again
if (file.Proper)
return false;
}
//There will never be a time when the episode quality is less than what we have and we want it... ever.... I think.
if (file.Quality > episode.Quality)
return false;
//Now we need to handle upgrades and actually pay attention to the Cutoff Value
if (file.Quality < episode.Quality)
{
var series = _series.GetSeries(episode.SeriesId);
var quality = _quality.Find(series.QualityProfileId);
if (quality.Cutoff <= file.Quality)
{
//If the episodeFile is a Proper we don't need to download again
if (file.Proper)
return false;
}
}
}
}

View File

@ -51,16 +51,19 @@ namespace NzbDrone.Core.Providers
{
var episodesInFile = Parser.ParseEpisodeInfo(filePath);
var episodes = new List<Episode>();
foreach (var parsedEpisode in episodesInFile)
{
EpisodeParseResult closureEpisode = parsedEpisode;
var episode = _episodeProvider.GetEpisode(series.SeriesId, closureEpisode.SeasonNumber, closureEpisode.EpisodeNumber);
var episode = _episodeProvider.GetEpisode(series.SeriesId, closureEpisode.SeasonNumber,
closureEpisode.EpisodeNumber);
episodes.Add(episode);
if (episode != null)
{
var episodeFile = new EpisodeFile();
episodeFile.DateAdded = DateTime.Now;
episodeFile.SeriesId = series.SeriesId;
episodeFile.EpisodeId = episode.EpisodeId;
episodeFile.Episodes = episodes;
episodeFile.Path = Parser.NormalizePath(filePath);
episodeFile.Size = _diskProvider.GetSize(filePath);
episodeFile.Quality = Parser.ParseQuality(filePath);