mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Fixed: Repack Preference Ignored
(cherry picked from commit 04447d9d4db8cc3d54baf0a721f4430cf77908c4)
This commit is contained in:
parent
c63b08265c
commit
25c9de857b
2 changed files with 104 additions and 1 deletions
|
@ -1,9 +1,11 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
|
@ -244,5 +246,88 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
.Should()
|
.Should()
|
||||||
.BeFalse();
|
.BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_when_repacks_are_not_preferred()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.DownloadPropersAndRepacks)
|
||||||
|
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||||
|
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.ReleaseGroup = "";
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.Quality = new QualityModel(Quality.FLAC);
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||||
|
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||||
|
.With(e => e.Albums = _albums)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_when_repack_but_auto_download_repacks_is_true()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.DownloadPropersAndRepacks)
|
||||||
|
.Returns(ProperDownloadTypes.PreferAndUpgrade);
|
||||||
|
|
||||||
|
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||||
|
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.ReleaseGroup = "Lidarr";
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.Quality = new QualityModel(Quality.FLAC);
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||||
|
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||||
|
.With(e => e.Albums = _albums)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_false_when_repack_but_auto_download_repacks_is_false()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IConfigService>()
|
||||||
|
.Setup(s => s.DownloadPropersAndRepacks)
|
||||||
|
.Returns(ProperDownloadTypes.DoNotUpgrade);
|
||||||
|
|
||||||
|
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||||
|
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.ReleaseGroup = "Lidarr";
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
_trackFiles.Select(c =>
|
||||||
|
{
|
||||||
|
c.Quality = new QualityModel(Quality.FLAC);
|
||||||
|
return c;
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var remoteAlbum = Builder<RemoteAlbum>.CreateNew()
|
||||||
|
.With(e => e.ParsedAlbumInfo = _parsedAlbumInfo)
|
||||||
|
.With(e => e.Albums = _albums)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(remoteAlbum, null).Accepted.Should().BeFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
{
|
{
|
||||||
|
@ -11,12 +13,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
{
|
{
|
||||||
private readonly IMediaFileService _mediaFileService;
|
private readonly IMediaFileService _mediaFileService;
|
||||||
private readonly UpgradableSpecification _upgradableSpecification;
|
private readonly UpgradableSpecification _upgradableSpecification;
|
||||||
|
private readonly IConfigService _configService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public RepackSpecification(IMediaFileService mediaFileService, UpgradableSpecification upgradableSpecification, Logger logger)
|
public RepackSpecification(IMediaFileService mediaFileService, UpgradableSpecification upgradableSpecification, IConfigService configService, Logger logger)
|
||||||
{
|
{
|
||||||
_mediaFileService = mediaFileService;
|
_mediaFileService = mediaFileService;
|
||||||
_upgradableSpecification = upgradableSpecification;
|
_upgradableSpecification = upgradableSpecification;
|
||||||
|
_configService = configService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +34,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
return Decision.Accept();
|
return Decision.Accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
|
||||||
|
|
||||||
|
if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer)
|
||||||
|
{
|
||||||
|
_logger.Debug("Repacks are not preferred, skipping check");
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var album in subject.Albums)
|
foreach (var album in subject.Albums)
|
||||||
{
|
{
|
||||||
var releaseGroup = subject.ParsedAlbumInfo.ReleaseGroup;
|
var releaseGroup = subject.ParsedAlbumInfo.ReleaseGroup;
|
||||||
|
@ -39,6 +51,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
{
|
{
|
||||||
if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedAlbumInfo.Quality))
|
if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedAlbumInfo.Quality))
|
||||||
{
|
{
|
||||||
|
if (downloadPropersAndRepacks == ProperDownloadTypes.DoNotUpgrade)
|
||||||
|
{
|
||||||
|
_logger.Debug("Auto downloading of repacks is disabled");
|
||||||
|
return Decision.Reject("Repack downloading is disabled");
|
||||||
|
}
|
||||||
|
|
||||||
var fileReleaseGroup = file.ReleaseGroup;
|
var fileReleaseGroup = file.ReleaseGroup;
|
||||||
|
|
||||||
if (fileReleaseGroup.IsNullOrWhiteSpace())
|
if (fileReleaseGroup.IsNullOrWhiteSpace())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue