diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs index fd8fa0345..9c6596be4 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedEpisodesFixture.cs @@ -48,7 +48,6 @@ public void Setup() Episodes = new List {episode}, Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilit.avi".AsOsAgnostic(), Quality = new QualityModel(Quality.Bluray720p) - })); } @@ -125,5 +124,32 @@ public void should_not_trigger_EpisodeImportedEvent_for_existing_files() Mocker.GetMock() .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); } + + [Test] + public void should_import_larger_files_first() + { + var fileDecision = _approvedDecisions.First(); + fileDecision.LocalEpisode.Size = 1.Gigabytes(); + + var sampleDecision = new ImportDecision + (new LocalEpisode + { + Series = fileDecision.LocalEpisode.Series, + Episodes = new List {fileDecision.LocalEpisode.Episodes.First()}, + Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilit.avi".AsOsAgnostic(), + Quality = new QualityModel(Quality.Bluray720p), + Size = 80.Megabytes() + }); + + + var all = new List(); + all.Add(fileDecision); + all.Add(sampleDecision); + + var results = Subject.Import(all); + + results.Should().HaveCount(1); + results.Should().ContainSingle(d => d.LocalEpisode.Size == fileDecision.LocalEpisode.Size); + } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs index 6b56d4d00..86d10675e 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs @@ -94,6 +94,7 @@ private List GetQualifiedImports(List decisions) { return decisions.Where(c => c.Approved) .OrderByDescending(c => c.LocalEpisode.Quality) + .ThenByDescending(c => c.LocalEpisode.Size) .ToList(); } }