diff --git a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs index b09def40c..725e1f5f6 100644 --- a/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs +++ b/src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFilesFixture.cs @@ -11,12 +11,12 @@ using NzbDrone.Core.Qualities; namespace NzbDrone.Core.Test.Housekeeping.Housekeepers { [TestFixture] - public class CleanupOrphanedEpisodeFilesFixture : DbTest + public class CleanupOrphanedEpisodeFilesFixture : DbTest { [Test] public void should_delete_orphaned_episode_files() { - var episodeFile = Builder.CreateNew() + var episodeFile = Builder.CreateNew() .With(h => h.Quality = new QualityModel()) .BuildNew(); @@ -28,22 +28,22 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers [Test] public void should_not_delete_unorphaned_episode_files() { - var episodeFiles = Builder.CreateListOfSize(2) + var episodeFiles = Builder.CreateListOfSize(2) .All() .With(h => h.Quality = new QualityModel()) .BuildListOfNew(); Db.InsertMany(episodeFiles); - var episode = Builder.CreateNew() - .With(e => e.EpisodeFileId = episodeFiles.First().Id) + var episode = Builder.CreateNew() + .With(e => e.MovieFileId = episodeFiles.First().Id) .BuildNew(); Db.Insert(episode); Subject.Clean(); AllStoredModels.Should().HaveCount(1); - Db.All().Should().Contain(e => e.EpisodeFileId == AllStoredModels.First().Id); + Db.All().Should().Contain(e => e.MovieFileId == AllStoredModels.First().Id); } } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 5c17b6b09..1e6c86abf 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -117,45 +117,43 @@ namespace NzbDrone.Core.Download.Pending foreach (var pendingRelease in GetPendingReleases()) { - //foreach (var episode in pendingRelease.RemoteEpisode.Episodes) - //{ - var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie)); - - if (ect < nextRssSync.Value) - { - ect = nextRssSync.Value; - } - else - { - ect = ect.AddMinutes(_configService.RssSyncInterval); - } - - var queue = new Queue.Queue - { - Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie), - Series = null, - Episode = null, - Movie = pendingRelease.RemoteMovie.Movie, - Quality = pendingRelease.RemoteMovie.ParsedMovieInfo.Quality, - Title = pendingRelease.Title, - Size = pendingRelease.RemoteMovie.Release.Size, - Sizeleft = pendingRelease.RemoteMovie.Release.Size, - RemoteMovie = pendingRelease.RemoteMovie, - Timeleft = ect.Subtract(DateTime.UtcNow), - EstimatedCompletionTime = ect, - Status = "Pending", - Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol - }; - queued.Add(queue); - //} + var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie)); + + if (ect < nextRssSync.Value) + { + ect = nextRssSync.Value; + } + else + { + ect = ect.AddMinutes(_configService.RssSyncInterval); + } + + var queue = new Queue.Queue + { + Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie), + Series = null, + Episode = null, + Movie = pendingRelease.RemoteMovie.Movie, + Quality = pendingRelease.RemoteMovie.ParsedMovieInfo?.Quality ?? new QualityModel(), + Title = pendingRelease.Title, + Size = pendingRelease.RemoteMovie.Release.Size, + Sizeleft = pendingRelease.RemoteMovie.Release.Size, + RemoteMovie = pendingRelease.RemoteMovie, + Timeleft = ect.Subtract(DateTime.UtcNow), + EstimatedCompletionTime = ect, + Status = "Pending", + Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol + }; + + queued.Add(queue); } //Return best quality release for each episode - var deduped = queued.GroupBy(q => q.Episode.Id).Select(g => + var deduped = queued.GroupBy(q => q.Movie.Id).Select(g => { - var series = g.First().Series; + var movies = g.First().Movie; - return g.OrderByDescending(e => e.Quality, new QualityModelComparer(series.Profile)) + return g.OrderByDescending(e => e.Quality, new QualityModelComparer(movies.Profile)) .ThenBy(q => PrioritizeDownloadProtocol(q.Movie, q.Protocol)) .First(); }); @@ -254,12 +252,12 @@ namespace NzbDrone.Core.Download.Pending return new[] { delay, minimumAge }.Max(); } - private void RemoveGrabbed(RemoteMovie remoteEpisode) + private void RemoveGrabbed(RemoteMovie remoteMovie) { var pendingReleases = GetPendingReleases(); - var existingReports = pendingReleases.Where(r => r.RemoteMovie.Movie.Id == remoteEpisode.Movie.Id) + var existingReports = pendingReleases.Where(r => r.RemoteMovie.Movie.Id == remoteMovie.Movie.Id) .ToList(); if (existingReports.Empty()) @@ -267,11 +265,11 @@ namespace NzbDrone.Core.Download.Pending return; } - var profile = remoteEpisode.Movie.Profile.Value; + var profile = remoteMovie.Movie.Profile.Value; foreach (var existingReport in existingReports) { - var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedMovieInfo.Quality, + var compare = new QualityModelComparer(profile).Compare(remoteMovie.ParsedMovieInfo.Quality, existingReport.RemoteMovie.ParsedMovieInfo.Quality); //Only remove lower/equal quality pending releases diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs index 79f186a37..a5cc3887c 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedEpisodeFiles.cs @@ -15,12 +15,12 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { var mapper = _database.GetDataMapper(); - mapper.ExecuteNonQuery(@"DELETE FROM EpisodeFiles + mapper.ExecuteNonQuery(@"DELETE FROM MovieFiles WHERE Id IN ( - SELECT EpisodeFiles.Id FROM EpisodeFiles - LEFT OUTER JOIN Episodes - ON EpisodeFiles.Id = Episodes.EpisodeFileId - WHERE Episodes.Id IS NULL)"); + SELECT MovieFiles.Id FROM MovieFiles + LEFT OUTER JOIN Movies + ON MovieFiles.Id = Movies.MovieFileId + WHERE Movies.Id IS NULL)"); } } } diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs index 63debb4b7..fb913e0a0 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { var mapper = _database.GetDataMapper(); - var usedTags = new[] { "Series", "Notifications", "DelayProfiles", "Restrictions" } + var usedTags = new[] { "Movies", "Series", "Notifications", "DelayProfiles", "Restrictions" } .SelectMany(v => GetUsedTags(v, mapper)) .Distinct() .ToArray(); diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs index 16b19c505..907d61817 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/UpdateCleanTitleForSeries.cs @@ -6,21 +6,21 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers { public class UpdateCleanTitleForSeries : IHousekeepingTask { - private readonly ISeriesRepository _seriesRepository; + private readonly IMovieRepository _movieRepository; - public UpdateCleanTitleForSeries(ISeriesRepository seriesRepository) + public UpdateCleanTitleForSeries(IMovieRepository movieRepository) { - _seriesRepository = seriesRepository; + _movieRepository = movieRepository; } public void Clean() { - var series = _seriesRepository.All().ToList(); + var movies = _movieRepository.All().ToList(); - series.ForEach(s => + movies.ForEach(m => { - s.CleanTitle = s.CleanTitle.CleanSeriesTitle(); - _seriesRepository.Update(s); + m.CleanTitle = m.CleanTitle.CleanSeriesTitle(); + _movieRepository.Update(m); }); } } diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs index 4c00a7d32..519ea3125 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Indexers.HDBits Peers = result.Leechers + result.Seeders, PublishDate = result.Added.ToUniversalTime(), Internal = internalRelease, - ImdbId = result.ImdbInfo.Id + ImdbId = result.ImdbInfo?.Id ?? 0 }); }