New: Pass DownloadClientItem to Import Specs

pull/6/head
ta264 4 years ago
parent b54d556e63
commit 34b1d429be

@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision<LocalTrack>(localTrack));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), null))
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>(), null))
.Returns(imported);
Mocker.GetMock<IImportApprovedTracks>()
@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.MediaFiles
Subject.ProcessRootFolder(DiskProvider.GetDirectoryInfo(_droneFactory));
Mocker.GetMock<IMakeImportDecision>()
.Verify(c => c.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()),
.Verify(c => c.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>(), It.IsAny<ParsedTrackInfo>()),
Times.Never());
VerifyNoImport();
@ -181,7 +181,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision<LocalTrack>(localTrack));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), null))
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>(), null))
.Returns(imported);
Mocker.GetMock<IImportApprovedTracks>()
@ -238,7 +238,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision<LocalTrack>(localTrack));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), null))
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>(), null))
.Returns(imported);
Mocker.GetMock<IImportApprovedTracks>()
@ -278,7 +278,7 @@ namespace NzbDrone.Core.Test.MediaFiles
imported.Add(new ImportDecision<LocalTrack>(localTrack));
Mocker.GetMock<IMakeImportDecision>()
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), null))
.Setup(s => s.GetImportDecisions(It.IsAny<List<IFileInfo>>(), It.IsAny<Artist>(), It.IsAny<DownloadClientItem>(), null))
.Returns(imported);
Mocker.GetMock<IImportApprovedTracks>()

@ -65,21 +65,21 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
_fail2 = new Mock<IImportDecisionEngineSpecification<LocalTrack>>();
_fail3 = new Mock<IImportDecisionEngineSpecification<LocalTrack>>();
_albumpass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Accept());
_albumpass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Accept());
_albumpass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Accept());
_albumpass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_albumpass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_albumpass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_albumfail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Reject("_albumfail1"));
_albumfail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Reject("_albumfail2"));
_albumfail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>())).Returns(Decision.Reject("_albumfail3"));
_albumfail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail1"));
_albumfail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail2"));
_albumfail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_albumfail3"));
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Accept());
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail1"));
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail2"));
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail3"));
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_fail1"));
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_fail2"));
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>())).Returns(Decision.Reject("_fail3"));
_artist = Builder<Artist>.CreateNew()
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
@ -150,12 +150,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
Subject.GetImportDecisions(_fileInfos, new Artist(), null, null, downloadClientItem, null, FilterFilesType.None, false, false, false);
_albumfail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumfail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumfail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumpass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumpass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumpass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>()), Times.Once());
_albumfail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
_albumfail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
_albumfail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
_albumpass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
_albumpass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
_albumpass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalAlbumRelease>(), It.IsAny<DownloadClientItem>()), Times.Once());
}
[Test]
@ -167,12 +167,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
Subject.GetImportDecisions(_fileInfos, new Artist(), null, null, downloadClientItem, null, FilterFilesType.None, false, false, false);
_fail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_fail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Once());
_fail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
_fail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Once());
}
[Test]
@ -185,12 +185,12 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
Subject.GetImportDecisions(_fileInfos, new Artist(), null, null, downloadClientItem, null, FilterFilesType.None, false, false, false);
_fail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_fail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_fail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>()), Times.Never());
_fail1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
_fail2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
_fail3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
_pass3.Verify(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>()), Times.Never());
}
[Test]

@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenFileSize(100.Megabytes());
GivenFreeSpace(80.Megabytes());
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
ExceptionVerification.ExpectedWarns(1);
}
@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenFileSize(100.Megabytes());
GivenFreeSpace(150.Megabytes());
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
ExceptionVerification.ExpectedWarns(1);
}
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenFileSize(100.Megabytes());
GivenFreeSpace(1.Gigabytes());
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -94,7 +94,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenFileSize(100.Megabytes());
GivenFreeSpace(1.Gigabytes());
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.GetAvailableSpace(_rootFolder), Times.Once());
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenFileSize(100.Megabytes());
GivenFreeSpace(null);
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Setup(s => s.GetAvailableSpace(It.IsAny<string>()))
.Throws(new TestException());
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
ExceptionVerification.ExpectedErrors(1);
}
@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
{
_localTrack.ExistingFile = true;
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
Mocker.GetMock<IDiskProvider>()
.Verify(s => s.GetAvailableSpace(It.IsAny<string>()), Times.Never());
@ -142,7 +142,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Setup(s => s.GetAvailableSpace(It.IsAny<string>()))
.Returns(freeSpace);
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -152,7 +152,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Setup(s => s.SkipFreeSpaceCheckWhenImporting)
.Returns(true);
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
}
}

@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
[Test]
public void should_return_true_if_not_in_working_folder()
{
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenInWorkingFolder();
GivenLastWriteTimeUtc(DateTime.UtcNow.AddHours(-1));
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenInWorkingFolder();
GivenLastWriteTimeUtc(DateTime.UtcNow);
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
[Test]
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
GivenInWorkingFolder();
GivenLastWriteTimeUtc(DateTime.UtcNow.AddDays(-5));
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
}
}

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.With(e => e.TrackFileId = 0)
.BuildList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
}
}

@ -51,7 +51,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
[Test]
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
[Test]
@ -156,7 +156,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
[Test]
@ -177,7 +177,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeFalse();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeFalse();
}
[Test]
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -221,7 +221,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
[Test]
@ -234,7 +234,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Specifications
.Build()
.ToList();
Subject.IsSatisfiedBy(_localTrack).Accepted.Should().BeTrue();
Subject.IsSatisfiedBy(_localTrack, null).Accepted.Should().BeTrue();
}
}
}

@ -200,7 +200,7 @@ namespace NzbDrone.Core.MediaFiles
}
}
var decisions = _importDecisionMaker.GetImportDecisions(audioFiles, artist, trackInfo);
var decisions = _importDecisionMaker.GetImportDecisions(audioFiles, artist, downloadClientItem, trackInfo);
var importResults = _importApprovedTracks.Import(decisions, true, downloadClientItem, importMode);
if (importMode == ImportMode.Auto)
@ -259,7 +259,7 @@ namespace NzbDrone.Core.MediaFiles
}
}
var decisions = _importDecisionMaker.GetImportDecisions(new List<IFileInfo>() { fileInfo }, artist, null);
var decisions = _importDecisionMaker.GetImportDecisions(new List<IFileInfo>() { fileInfo }, artist, downloadClientItem, null);
return _importApprovedTracks.Import(decisions, true, downloadClientItem, importMode);
}

@ -1,9 +1,10 @@
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
namespace NzbDrone.Core.MediaFiles.TrackImport
{
public interface IImportDecisionEngineSpecification<T>
{
Decision IsSatisfiedBy(T item);
Decision IsSatisfiedBy(T item, DownloadClientItem downloadClientItem);
}
}

@ -18,7 +18,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
public interface IMakeImportDecision
{
List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, FilterFilesType filter, bool includeExisting);
List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, ParsedTrackInfo folderInfo);
List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo);
List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, Album album, AlbumRelease albumRelease, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo, FilterFilesType filter, bool newDownload, bool singleRelease, bool includeExisting);
}
@ -66,9 +66,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
return GetImportDecisions(musicFiles, artist, null, null, null, null, filter, false, false, true);
}
public List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, ParsedTrackInfo folderInfo)
public List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo)
{
return GetImportDecisions(musicFiles, artist, null, null, null, folderInfo, FilterFilesType.None, true, false, false);
return GetImportDecisions(musicFiles, artist, null, null, downloadClientItem, folderInfo, FilterFilesType.None, true, false, false);
}
public List<ImportDecision<LocalTrack>> GetImportDecisions(List<IFileInfo> musicFiles, Artist artist, Album album, AlbumRelease albumRelease, DownloadClientItem downloadClientItem, ParsedTrackInfo folderInfo, FilterFilesType filter, bool newDownload, bool singleRelease, bool includeExisting)
@ -136,13 +136,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
foreach (var release in releases)
{
release.NewDownload = newDownload;
var releaseDecision = GetDecision(release);
var releaseDecision = GetDecision(release, downloadClientItem);
foreach (var localTrack in release.LocalTracks)
{
if (releaseDecision.Approved)
{
decisions.AddIfNotNull(GetDecision(localTrack));
decisions.AddIfNotNull(GetDecision(localTrack, downloadClientItem));
}
else
{
@ -154,7 +154,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
return decisions;
}
private ImportDecision<LocalAlbumRelease> GetDecision(LocalAlbumRelease localAlbumRelease)
private ImportDecision<LocalAlbumRelease> GetDecision(LocalAlbumRelease localAlbumRelease, DownloadClientItem downloadClientItem)
{
ImportDecision<LocalAlbumRelease> decision = null;
@ -164,7 +164,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
}
else
{
var reasons = _albumSpecifications.Select(c => EvaluateSpec(c, localAlbumRelease))
var reasons = _albumSpecifications.Select(c => EvaluateSpec(c, localAlbumRelease, downloadClientItem))
.Where(c => c != null);
decision = new ImportDecision<LocalAlbumRelease>(localAlbumRelease, reasons.ToArray());
@ -186,7 +186,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
return decision;
}
private ImportDecision<LocalTrack> GetDecision(LocalTrack localTrack)
private ImportDecision<LocalTrack> GetDecision(LocalTrack localTrack, DownloadClientItem downloadClientItem)
{
ImportDecision<LocalTrack> decision = null;
@ -197,7 +197,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
}
else
{
var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localTrack))
var reasons = _trackSpecifications.Select(c => EvaluateSpec(c, localTrack, downloadClientItem))
.Where(c => c != null);
decision = new ImportDecision<LocalTrack>(localTrack, reasons.ToArray());
@ -219,11 +219,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
return decision;
}
private Rejection EvaluateSpec<T>(IImportDecisionEngineSpecification<T> spec, T item)
private Rejection EvaluateSpec<T>(IImportDecisionEngineSpecification<T> spec, T item, DownloadClientItem downloadClientItem)
{
try
{
var result = spec.IsSatisfiedBy(item);
var result = spec.IsSatisfiedBy(item, downloadClientItem);
if (!result.Accepted)
{

@ -105,18 +105,24 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual
private List<ManualImportItem> ProcessFolder(string folder, string downloadId, FilterFilesType filter, bool replaceExistingFiles)
{
DownloadClientItem downloadClientItem = null;
var directoryInfo = new DirectoryInfo(folder);
var artist = _parsingService.GetArtist(directoryInfo.Name);
if (artist == null && downloadId.IsNotNullOrWhiteSpace())
if (downloadId.IsNotNullOrWhiteSpace())
{
var trackedDownload = _trackedDownloadService.Find(downloadId);
artist = trackedDownload.RemoteAlbum?.Artist;
downloadClientItem = trackedDownload.DownloadItem;
if (artist == null)
{
artist = trackedDownload.RemoteAlbum?.Artist;
}
}
var folderInfo = Parser.Parser.ParseMusicTitle(directoryInfo.Name);
var artistFiles = _diskScanService.GetAudioFiles(folder).ToList();
var decisions = _importDecisionMaker.GetImportDecisions(artistFiles, artist, null, null, null, folderInfo, filter, true, false, !replaceExistingFiles);
var decisions = _importDecisionMaker.GetImportDecisions(artistFiles, artist, null, null, downloadClientItem, folderInfo, filter, true, false, !replaceExistingFiles);
// paths will be different for new and old files which is why we need to map separately
var newFiles = artistFiles.Join(decisions,

@ -1,6 +1,7 @@
using System.Linq;
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
@ -15,20 +16,20 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease)
public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem)
{
var artist = localAlbumRelease.AlbumRelease.Album.Value.Artist.Value;
var artist = item.AlbumRelease.Album.Value.Artist.Value;
var qualityComparer = new QualityModelComparer(artist.QualityProfile);
// check if we are changing release
var currentRelease = localAlbumRelease.AlbumRelease.Album.Value.AlbumReleases.Value.Single(x => x.Monitored);
var newRelease = localAlbumRelease.AlbumRelease;
var currentRelease = item.AlbumRelease.Album.Value.AlbumReleases.Value.Single(x => x.Monitored);
var newRelease = item.AlbumRelease;
// if we are, check we are upgrading
if (newRelease.Id != currentRelease.Id)
{
// min quality of all new tracks
var newMinQuality = localAlbumRelease.LocalTracks.Select(x => x.Quality).OrderBy(x => x, qualityComparer).First();
var newMinQuality = item.LocalTracks.Select(x => x.Quality).OrderBy(x => x, qualityComparer).First();
_logger.Debug("Min quality of new files: {0}", newMinQuality);
// get minimum quality of existing release
@ -39,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger.Debug("Min quality of existing files: {0}", existingMinQuality);
if (qualityComparer.Compare(existingMinQuality, newMinQuality) > 0)
{
_logger.Debug("This album isn't a quality upgrade for all tracks. Skipping {0}", localAlbumRelease);
_logger.Debug("This album isn't a quality upgrade for all tracks. Skipping {0}", item);
return Decision.Reject("Not an upgrade for existing album file(s)");
}
}

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -17,23 +18,23 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease)
public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem)
{
double dist;
string reasons;
// strict when a new download
if (localAlbumRelease.NewDownload)
if (item.NewDownload)
{
dist = localAlbumRelease.Distance.NormalizedDistance();
reasons = localAlbumRelease.Distance.Reasons;
dist = item.Distance.NormalizedDistance();
reasons = item.Distance.Reasons;
if (dist > _albumThreshold)
{
_logger.Debug($"Album match is not close enough: {dist} vs {_albumThreshold} {reasons}. Skipping {localAlbumRelease}");
_logger.Debug($"Album match is not close enough: {dist} vs {_albumThreshold} {reasons}. Skipping {item}");
return Decision.Reject($"Album match is not close enough: {1 - dist:P1} vs {1 - _albumThreshold:P0} {reasons}");
}
var worstTrackMatch = localAlbumRelease.LocalTracks.Where(x => x.Distance != null).OrderByDescending(x => x.Distance.NormalizedDistance()).FirstOrDefault();
var worstTrackMatch = item.LocalTracks.Where(x => x.Distance != null).OrderByDescending(x => x.Distance.NormalizedDistance()).FirstOrDefault();
if (worstTrackMatch == null)
{
_logger.Debug($"No tracks matched");
@ -45,7 +46,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
var trackReasons = worstTrackMatch.Distance.Reasons;
if (maxTrackDist > _trackThreshold)
{
_logger.Debug($"Worst track match: {maxTrackDist} vs {_trackThreshold} {trackReasons}. Skipping {localAlbumRelease}");
_logger.Debug($"Worst track match: {maxTrackDist} vs {_trackThreshold} {trackReasons}. Skipping {item}");
return Decision.Reject($"Worst track match: {1 - maxTrackDist:P1} vs {1 - _trackThreshold:P0} {trackReasons}");
}
}
@ -55,16 +56,16 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
else
{
// get album distance ignoring whether tracks are missing
dist = localAlbumRelease.Distance.NormalizedDistanceExcluding(new List<string> { "missing_tracks", "unmatched_tracks" });
reasons = localAlbumRelease.Distance.Reasons;
dist = item.Distance.NormalizedDistanceExcluding(new List<string> { "missing_tracks", "unmatched_tracks" });
reasons = item.Distance.Reasons;
if (dist > _albumThreshold)
{
_logger.Debug($"Album match is not close enough: {dist} vs {_albumThreshold} {reasons}. Skipping {localAlbumRelease}");
_logger.Debug($"Album match is not close enough: {dist} vs {_albumThreshold} {reasons}. Skipping {item}");
return Decision.Reject($"Album match is not close enough: {1 - dist:P1} vs {1 - _albumThreshold:P0} {reasons}");
}
}
_logger.Debug($"Accepting release {localAlbumRelease}: dist {dist} vs {_albumThreshold} {reasons}");
_logger.Debug($"Accepting release {item}: dist {dist} vs {_albumThreshold} {reasons}");
return Decision.Accept();
}
}

@ -1,5 +1,6 @@
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -14,14 +15,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
var dist = localTrack.Distance.NormalizedDistance();
var reasons = localTrack.Distance.Reasons;
var dist = item.Distance.NormalizedDistance();
var reasons = item.Distance.Reasons;
if (dist > _threshold)
{
_logger.Debug($"Track match is not close enough: {dist} vs {_threshold} {reasons}. Skipping {localTrack}");
_logger.Debug($"Track match is not close enough: {dist} vs {_threshold} {reasons}. Skipping {item}");
return Decision.Reject($"Track match is not close enough: {1 - dist:P1} vs {1 - _threshold:P0} {reasons}");
}

@ -4,6 +4,7 @@ using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -21,7 +22,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
if (_configService.SkipFreeSpaceCheckWhenImporting)
{
@ -31,13 +32,13 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
try
{
if (localTrack.ExistingFile)
if (item.ExistingFile)
{
_logger.Debug("Skipping free space check for existing track");
return Decision.Accept();
}
var path = Directory.GetParent(localTrack.Artist.Path);
var path = Directory.GetParent(item.Artist.Path);
var freeSpace = _diskProvider.GetAvailableSpace(path.FullName);
if (!freeSpace.HasValue)
@ -46,9 +47,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
return Decision.Accept();
}
if (freeSpace < localTrack.Size + _configService.MinimumFreeSpaceWhenImporting.Megabytes())
if (freeSpace < item.Size + _configService.MinimumFreeSpaceWhenImporting.Megabytes())
{
_logger.Warn("Not enough free space ({0}) to import: {1} ({2})", freeSpace, localTrack, localTrack.Size);
_logger.Warn("Not enough free space ({0}) to import: {1} ({2})", freeSpace, item, item.Size);
return Decision.Reject("Not enough free space");
}
}
@ -58,7 +59,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
}
catch (Exception ex)
{
_logger.Error(ex, "Unable to check free disk space while importing. {0}", localTrack.Path);
_logger.Error(ex, "Unable to check free disk space while importing. {0}", item.Path);
}
return Decision.Accept();

@ -1,6 +1,7 @@
using System.Linq;
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -14,18 +15,18 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease)
public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem)
{
var existingRelease = localAlbumRelease.AlbumRelease.Album.Value.AlbumReleases.Value.Single(x => x.Monitored);
var existingRelease = item.AlbumRelease.Album.Value.AlbumReleases.Value.Single(x => x.Monitored);
var existingTrackCount = existingRelease.Tracks.Value.Count(x => x.HasFile);
if (localAlbumRelease.AlbumRelease.Id != existingRelease.Id &&
localAlbumRelease.TrackCount < existingTrackCount)
if (item.AlbumRelease.Id != existingRelease.Id &&
item.TrackCount < existingTrackCount)
{
_logger.Debug($"This release has fewer tracks ({localAlbumRelease.TrackCount}) than existing {existingRelease} ({existingTrackCount}). Skipping {localAlbumRelease}");
_logger.Debug($"This release has fewer tracks ({item.TrackCount}) than existing {existingRelease} ({existingTrackCount}). Skipping {item}");
return Decision.Reject("Has fewer tracks than existing release");
}
_logger.Trace("Accepting release {0}", localAlbumRelease);
_logger.Trace("Accepting release {0}", item);
return Decision.Accept();
}
}

@ -1,5 +1,6 @@
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -13,17 +14,17 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease)
public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem)
{
if (localAlbumRelease.NewDownload && localAlbumRelease.TrackMapping.LocalExtra.Count > 0)
if (item.NewDownload && item.TrackMapping.LocalExtra.Count > 0)
{
_logger.Debug("This release has track files that have not been matched. Skipping {0}", localAlbumRelease);
_logger.Debug("This release has track files that have not been matched. Skipping {0}", item);
return Decision.Reject("Has unmatched tracks");
}
if (localAlbumRelease.NewDownload && localAlbumRelease.TrackMapping.MBExtra.Count > 0)
if (item.NewDownload && item.TrackMapping.MBExtra.Count > 0)
{
_logger.Debug("This release is missing tracks. Skipping {0}", localAlbumRelease);
_logger.Debug("This release is missing tracks. Skipping {0}", item);
return Decision.Reject("Has missing tracks");
}

@ -5,6 +5,7 @@ using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -22,30 +23,30 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
if (localTrack.ExistingFile)
if (item.ExistingFile)
{
_logger.Debug("{0} is in artist folder, skipping unpacking check", localTrack.Path);
_logger.Debug("{0} is in artist folder, skipping unpacking check", item.Path);
return Decision.Accept();
}
foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|'))
{
DirectoryInfo parent = Directory.GetParent(localTrack.Path);
DirectoryInfo parent = Directory.GetParent(item.Path);
while (parent != null)
{
if (parent.Name.StartsWith(workingFolder))
{
if (OsInfo.IsNotWindows)
{
_logger.Debug("{0} is still being unpacked", localTrack.Path);
_logger.Debug("{0} is still being unpacked", item.Path);
return Decision.Reject("File is still being unpacked");
}
if (_diskProvider.FileGetLastWrite(localTrack.Path) > DateTime.UtcNow.AddMinutes(-5))
if (_diskProvider.FileGetLastWrite(item.Path) > DateTime.UtcNow.AddMinutes(-5))
{
_logger.Debug("{0} appears to be unpacking still", localTrack.Path);
_logger.Debug("{0} appears to be unpacking still", item.Path);
return Decision.Reject("File is still being unpacked");
}
}

@ -1,5 +1,6 @@
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -13,14 +14,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalAlbumRelease localAlbumRelease)
public Decision IsSatisfiedBy(LocalAlbumRelease item, DownloadClientItem downloadClientItem)
{
if (localAlbumRelease.AlbumRelease.Monitored || localAlbumRelease.AlbumRelease.Album.Value.AnyReleaseOk)
if (item.AlbumRelease.Monitored || item.AlbumRelease.Album.Value.AnyReleaseOk)
{
return Decision.Accept();
}
_logger.Debug("AlbumRelease {0} was not requested", localAlbumRelease);
_logger.Debug("AlbumRelease {0} was not requested", item);
return Decision.Reject("Album release not requested");
}
}

@ -1,6 +1,7 @@
using System.Linq;
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -14,9 +15,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
var trackFiles = localTrack.Tracks.Where(e => e.TrackFileId != 0).Select(e => e.TrackFile).ToList();
var trackFiles = item.Tracks.Where(e => e.TrackFileId != 0).Select(e => e.TrackFile).ToList();
if (trackFiles.Count == 0)
{
@ -30,9 +31,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
return Decision.Accept();
}
if (trackFiles.First().Value.Size == localTrack.Size)
if (trackFiles.First().Value.Size == item.Size)
{
_logger.Debug("'{0}' Has the same filesize as existing file", localTrack.Path);
_logger.Debug("'{0}' Has the same filesize as existing file", item.Path);
return Decision.Reject("Has the same filesize as existing file");
}

@ -1,6 +1,7 @@
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
@ -18,9 +19,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
public RejectionType Type => RejectionType.Permanent;
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
if (_sameTracksSpecification.IsSatisfiedBy(localTrack.Tracks))
if (_sameTracksSpecification.IsSatisfiedBy(item.Tracks))
{
return Decision.Accept();
}

@ -2,6 +2,7 @@ using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
@ -18,12 +19,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
_logger = logger;
}
public Decision IsSatisfiedBy(LocalTrack localTrack)
public Decision IsSatisfiedBy(LocalTrack item, DownloadClientItem downloadClientItem)
{
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
var qualityComparer = new QualityModelComparer(localTrack.Artist.QualityProfile);
var qualityComparer = new QualityModelComparer(item.Artist.QualityProfile);
foreach (var track in localTrack.Tracks.Where(e => e.TrackFileId > 0))
foreach (var track in item.Tracks.Where(e => e.TrackFileId > 0))
{
var trackFile = track.TrackFile.Value;
@ -33,18 +34,18 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
continue;
}
var qualityCompare = qualityComparer.Compare(localTrack.Quality.Quality, trackFile.Quality.Quality);
var qualityCompare = qualityComparer.Compare(item.Quality.Quality, trackFile.Quality.Quality);
if (qualityCompare < 0)
{
_logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", localTrack.Path);
_logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", item.Path);
return Decision.Reject("Not an upgrade for existing track file(s)");
}
if (qualityCompare == 0 && downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
localTrack.Quality.Revision.CompareTo(trackFile.Quality.Revision) < 0)
item.Quality.Revision.CompareTo(trackFile.Quality.Revision) < 0)
{
_logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", localTrack.Path);
_logger.Debug("This file isn't a quality upgrade for all tracks. Skipping {0}", item.Path);
return Decision.Reject("Not an upgrade for existing track file(s)");
}
}

Loading…
Cancel
Save