mirror of https://github.com/Radarr/Radarr
Fixed: Saving IndexerSettings into DB which confuses the datamapper.
Fixes #2945
This commit is contained in:
parent
c4ca2f12bb
commit
b553d8aef6
|
@ -33,9 +33,18 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
IndexerId = 1,
|
||||
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp",
|
||||
Seeders = 0,
|
||||
IndexerSettings = new TorrentRssIndexerSettings {MinimumSeeders = 5}
|
||||
//IndexerSettings = new TorrentRssIndexerSettings {MinimumSeeders = 5}
|
||||
}
|
||||
};
|
||||
|
||||
_indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Settings = new TorrentRssIndexerSettings { MinimumSeeders = 5 }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(_indexerDefinition);
|
||||
}
|
||||
|
||||
private void GivenReleaseSeeders(int? seeders)
|
||||
|
@ -56,7 +65,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
}
|
||||
|
||||
// These tests are not needed anymore, since indexer settings are saved on the release itself!
|
||||
/*
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_indexer_not_specified()
|
||||
{
|
||||
|
@ -73,7 +82,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
.Callback<int>(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}*/
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_seeds_unknown()
|
||||
|
|
|
@ -3,7 +3,9 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Rarbg;
|
||||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Augmenters;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -13,15 +15,31 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests.AugmentersTests
|
|||
[TestFixture]
|
||||
public class AugmentWithReleaseInfoFixture : AugmentMovieInfoFixture<AugmentWithReleaseInfo>
|
||||
{
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private ReleaseInfo ReleaseInfoWithLanguages(params Language[] languages)
|
||||
{
|
||||
_indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Settings = new RarbgSettings { MultiLanguages = languages.ToList().Select(l => (int) l) }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(_indexerDefinition);
|
||||
|
||||
return new ReleaseInfo
|
||||
{
|
||||
IndexerSettings = new RarbgSettings
|
||||
{
|
||||
MultiLanguages = languages.ToList().Select(l => (int) l)
|
||||
}
|
||||
IndexerId = 1
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
@ -25,24 +26,33 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|||
{
|
||||
var torrentInfo = subject.Release;
|
||||
|
||||
if (torrentInfo == null || torrentInfo.IndexerSettings == null)
|
||||
|
||||
IIndexerSettings indexerSettings = null;
|
||||
try {
|
||||
indexerSettings = _indexerFactory.Get(subject.Release.IndexerId)?.Settings as IIndexerSettings;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Debug("Indexer with id {0} does not exist, skipping required indexer flags specs.", subject.Release.IndexerId);
|
||||
}
|
||||
|
||||
if (torrentInfo == null || indexerSettings == null)
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var torrentIndexerSettings = torrentInfo.IndexerSettings as ITorrentIndexerSettings;
|
||||
|
||||
if (torrentIndexerSettings != null)
|
||||
if (indexerSettings is ITorrentIndexerSettings torrentIndexerSettings)
|
||||
{
|
||||
var requiredFlags = torrentIndexerSettings.RequiredFlags;
|
||||
var requiredFlag = (IndexerFlags) 0;
|
||||
|
||||
if (requiredFlags == null || requiredFlags.Count() == 0)
|
||||
var enumerable = requiredFlags.ToList();
|
||||
if (requiredFlags == null || !enumerable.Any())
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
foreach (var flag in requiredFlags)
|
||||
|
||||
foreach (var flag in enumerable)
|
||||
{
|
||||
if (torrentInfo.IndexerFlags.HasFlag((IndexerFlags)flag))
|
||||
{
|
||||
|
@ -50,7 +60,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|||
}
|
||||
requiredFlag |= (IndexerFlags)flag;
|
||||
}
|
||||
|
||||
|
||||
_logger.Debug("None of the required indexer flags {0} where found. Found flags: {1}", requiredFlag, torrentInfo.IndexerFlags);
|
||||
return Decision.Reject("None of the required indexer flags {0} where found. Found flags: {1}", requiredFlag, torrentInfo.IndexerFlags);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Indexers;
|
||||
|
@ -19,19 +20,27 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|||
|
||||
//public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||
public RejectionType Type => RejectionType.Permanent;
|
||||
|
||||
|
||||
public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
var torrentInfo = subject.Release as TorrentInfo;
|
||||
|
||||
if (torrentInfo == null || torrentInfo.IndexerSettings == null)
|
||||
IIndexerSettings indexerSettings = null;
|
||||
try {
|
||||
indexerSettings = _indexerFactory.Get(subject.Release.IndexerId)?.Settings as IIndexerSettings;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Debug("Indexer with id {0} does not exist, skipping minimum seeder checks.", subject.Release.IndexerId);
|
||||
}
|
||||
|
||||
|
||||
if (torrentInfo == null || indexerSettings == null)
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var torrentIndexerSettings = torrentInfo.IndexerSettings as ITorrentIndexerSettings;
|
||||
|
||||
if (torrentIndexerSettings != null)
|
||||
if (indexerSettings is ITorrentIndexerSettings torrentIndexerSettings)
|
||||
{
|
||||
var minimumSeeders = torrentIndexerSettings.MinimumSeeders;
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
c.IndexerId = Definition.Id;
|
||||
c.Indexer = Definition.Name;
|
||||
c.IndexerSettings = Definition.Settings as IIndexerSettings;
|
||||
c.DownloadProtocol = Protocol;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Composition;
|
||||
|
@ -21,7 +22,7 @@ namespace NzbDrone.Core.Indexers
|
|||
public IndexerFactory(IIndexerStatusService indexerStatusService,
|
||||
IIndexerRepository providerRepository,
|
||||
IEnumerable<IIndexer> providers,
|
||||
IContainer container,
|
||||
IContainer container,
|
||||
IEventAggregator eventAggregator,
|
||||
Logger logger)
|
||||
: base(providerRepository, providers, container, eventAggregator, logger)
|
||||
|
@ -84,5 +85,7 @@ namespace NzbDrone.Core.Indexers
|
|||
yield return indexer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace NzbDrone.Core.Parser.Augmenters
|
|||
|
||||
if (int.TryParse(history.Data.GetValueOrDefault("indexerId"), out var indexerId))
|
||||
{
|
||||
var indexerSettings = _indexerFactory.Get(indexerId).Settings as IIndexerSettings;
|
||||
releaseInfo.IndexerSettings = indexerSettings;
|
||||
//var indexerSettings = _indexerFactory.Get(indexerId).Settings as IIndexerSettings;
|
||||
releaseInfo.IndexerId = indexerId;
|
||||
}
|
||||
|
||||
if (int.TryParse(history.Data.GetValueOrDefault("size"), out var size))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Parser.Augmenters
|
||||
|
@ -8,6 +9,13 @@ namespace NzbDrone.Core.Parser.Augmenters
|
|||
public class AugmentWithReleaseInfo : IAugmentParsedMovieInfo
|
||||
|
||||
{
|
||||
private readonly IIndexerFactory _indexerFactory;
|
||||
|
||||
public AugmentWithReleaseInfo(IIndexerFactory indexerFactory)
|
||||
{
|
||||
_indexerFactory = indexerFactory;
|
||||
}
|
||||
|
||||
public Type HelperType
|
||||
{
|
||||
get
|
||||
|
@ -18,17 +26,23 @@ namespace NzbDrone.Core.Parser.Augmenters
|
|||
|
||||
public ParsedMovieInfo AugmentMovieInfo(ParsedMovieInfo movieInfo, object helper)
|
||||
{
|
||||
var releaseInfo = helper as ReleaseInfo;
|
||||
|
||||
if (releaseInfo != null)
|
||||
if (helper is ReleaseInfo releaseInfo)
|
||||
{
|
||||
// First, let's augment the language!
|
||||
|
||||
IIndexerSettings indexerSettings = null;
|
||||
try {
|
||||
indexerSettings = _indexerFactory.Get(releaseInfo.IndexerId)?.Settings as IIndexerSettings;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//_logger.Debug("Indexer with id {0} does not exist, skipping minimum seeder checks.", subject.Release.IndexerId);
|
||||
} // First, let's augment the language!
|
||||
var languageTitle = movieInfo.SimpleReleaseTitle;
|
||||
if (movieInfo.MovieTitle.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
if (languageTitle.ToLower().Contains("multi") && releaseInfo?.IndexerSettings?.MultiLanguages?.Any() == true)
|
||||
if (languageTitle.ToLower().Contains("multi") && indexerSettings?.MultiLanguages?.Any() == true)
|
||||
{
|
||||
foreach (var i in releaseInfo.IndexerSettings.MultiLanguages)
|
||||
foreach (var i in indexerSettings.MultiLanguages)
|
||||
{
|
||||
var language = (Language) i;
|
||||
if (!movieInfo.Languages.Contains(language))
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace NzbDrone.Core.Parser.Model
|
|||
public string InfoUrl { get; set; }
|
||||
public string CommentUrl { get; set; }
|
||||
public int IndexerId { get; set; }
|
||||
public IIndexerSettings IndexerSettings { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public DownloadProtocol DownloadProtocol { get; set; }
|
||||
public int TvdbId { get; set; }
|
||||
|
|
Loading…
Reference in New Issue