From c4c3c4f6202edf4750e7f4bdf29602ab5bfabce4 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 23 Dec 2017 23:18:29 -0500 Subject: [PATCH] Fixed: Quality hierarchy not being honored during track import --- .../Specifications/UpgradeSpecificationFixture.cs | 2 +- .../TrackImport/Specifications/UpgradeSpecification.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs index 22158edf6..a745cb2ee 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/TrackImport/Specifications/UpgradeSpecificationFixture.cs @@ -131,7 +131,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications .With(e => e.TrackFile = new LazyLoaded( new TrackFile { - Quality = new QualityModel(Quality.MP3_320, new Revision(version: 1)), + Quality = new QualityModel(Quality.MP3_256, new Revision(version: 1)), Language = Language.English })) .Build() diff --git a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs b/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs index 05b10dd8d..24a3214ed 100644 --- a/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs +++ b/src/NzbDrone.Core/MediaFiles/TrackImport/Specifications/UpgradeSpecification.cs @@ -22,11 +22,17 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications var qualityComparer = new QualityModelComparer(localTrack.Artist.Profile); var languageComparer = new LanguageComparer(localTrack.Artist.LanguageProfile); + if (localTrack.Tracks.Any(e => e.TrackFileId != 0 && qualityComparer.Compare(e.TrackFile.Value.Quality, localTrack.Quality) > 0)) + { + _logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", localTrack.Path); + return Decision.Reject("Not an upgrade for existing track file(s)"); + } + if (localTrack.Tracks.Any(e => e.TrackFileId != 0 && languageComparer.Compare(e.TrackFile.Value.Language, localTrack.Language) > 0 && qualityComparer.Compare(e.TrackFile.Value.Quality, localTrack.Quality) == 0)) { - _logger.Debug("This file isn't an upgrade for all tracks. Skipping {0}", localTrack.Path); + _logger.Debug("This file isn't a language upgrade for all tracks. Skipping {0}", localTrack.Path); return Decision.Reject("Not an upgrade for existing track file(s)"); }