diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs index 9d5b7a40a..da4432241 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync _profile.Items = new List(); _profile.Items.Add(new QualityProfileQualityItem { Allowed = true, Quality = Quality.MP3_256 }); _profile.Items.Add(new QualityProfileQualityItem { Allowed = true, Quality = Quality.MP3_320 }); - _profile.Items.Add(new QualityProfileQualityItem { Allowed = true, Quality = Quality.MP3_320 }); + _profile.Items.Add(new QualityProfileQualityItem { Allowed = true, Quality = Quality.FLAC }); _profile.Cutoff = Quality.MP3_320.Id; @@ -185,10 +185,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync [Test] public void should_be_false_when_release_is_proper_for_existing_album_of_different_quality() { - _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_256, new Revision(version: 2)); + _remoteAlbum.ParsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)); _remoteAlbum.Release.PublishDate = DateTime.UtcNow; - GivenExistingFile(new QualityModel(Quality.MP3_192)); + GivenExistingFile(new QualityModel(Quality.MP3_256)); _delayProfile.UsenetDelay = 720; diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs index 623d66b97..8cbeba4d8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs @@ -64,16 +64,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { var trackFiles = _mediaFileService.GetFilesByAlbum(album.Id); - if (trackFiles.Any()) + foreach (var file in trackFiles) { - var currentQualities = trackFiles.Select(c => c.Quality).Distinct().ToList(); - - var upgradable = _upgradableSpecification.IsUpgradable(qualityProfile, - currentQualities, - _preferredWordServiceCalculator.Calculate(subject.Artist, trackFiles[0].GetSceneOrFileName()), - subject.ParsedAlbumInfo.Quality, - subject.PreferredWordScore); - if (upgradable) + var currentQuality = file.Quality; + var newQuality = subject.ParsedAlbumInfo.Quality; + var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality); + + if (qualityCompare == 0 && newQuality?.Revision.CompareTo(currentQuality.Revision) > 0) { _logger.Debug("New quality is a better revision for existing quality, skipping delay"); return Decision.Accept();