1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-24 22:35:49 -04:00

Fixed: Saving IndexerSettings into DB which confuses the datamapper.

Fixes #2945
This commit is contained in:
Leonardo Galli
2018-08-06 19:35:26 +02:00
parent c4ca2f12bb
commit b553d8aef6
9 changed files with 94 additions and 33 deletions
@@ -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;