New: Don't block imports when release was matched by ID if they were grabbed via interactive search

(cherry picked from commit bc2942c28d3c48e9eea61a68baf032ba181aef1e)
release-source-type
Mark McDowall 2 years ago committed by Bogdan
parent a3c33fe8cc
commit 3de5428efe

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
results.Should().NotBeEmpty();
Mocker.GetMock<IMakeDownloadDecision>()
.Verify(v => v.GetRssDecision(It.Is<List<ReleaseInfo>>(d => d.Count == 0)), Times.Never());
.Verify(v => v.GetRssDecision(It.Is<List<ReleaseInfo>>(d => d.Count == 0), It.IsAny<bool>()), Times.Never());
}
[Test]

@ -0,0 +1,14 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(067)]
public class add_additional_info_to_pending_releases : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("PendingReleases").AddColumn("AdditionalInfo").AsString().Nullable();
}
}
}

@ -229,6 +229,7 @@ namespace NzbDrone.Core.Datastore
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ParsedAlbumInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ParsedTrackInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ReleaseInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<PendingReleaseAdditionalInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<HashSet<int>>());
SqlMapper.AddTypeHandler(new OsPathConverter());
SqlMapper.RemoveTypeMap(typeof(Guid));

@ -16,7 +16,7 @@ namespace NzbDrone.Core.DecisionEngine
{
public interface IMakeDownloadDecision
{
List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports);
List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports, bool pushedRelease = false);
List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase);
}
@ -41,17 +41,17 @@ namespace NzbDrone.Core.DecisionEngine
_logger = logger;
}
public List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports)
public List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports, bool pushedRelease = false)
{
return GetAlbumDecisions(reports).ToList();
return GetAlbumDecisions(reports, pushedRelease).ToList();
}
public List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase)
{
return GetAlbumDecisions(reports, searchCriteriaBase).ToList();
return GetAlbumDecisions(reports, false, searchCriteriaBase).ToList();
}
private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteria = null)
private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> reports, bool pushedRelease, SearchCriteriaBase searchCriteria = null)
{
if (reports.Any())
{
@ -169,6 +169,26 @@ namespace NzbDrone.Core.DecisionEngine
if (decision != null)
{
var source = pushedRelease ? ReleaseSourceType.ReleasePush : ReleaseSourceType.Rss;
if (searchCriteria != null)
{
if (searchCriteria.InteractiveSearch)
{
source = ReleaseSourceType.InteractiveSearch;
}
else if (searchCriteria.UserInvokedSearch)
{
source = ReleaseSourceType.UserInvokedSearch;
}
else
{
source = ReleaseSourceType.Search;
}
}
decision.RemoteAlbum.ReleaseSource = source;
if (decision.Rejections.Any())
{
_logger.Debug("Release rejected for the following reasons: {0}", string.Join(", ", decision.Rejections));

@ -12,8 +12,14 @@ namespace NzbDrone.Core.Download.Pending
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
public ReleaseInfo Release { get; set; }
public PendingReleaseReason Reason { get; set; }
public PendingReleaseAdditionalInfo AdditionalInfo { get; set; }
// Not persisted
public RemoteAlbum RemoteAlbum { get; set; }
}
public class PendingReleaseAdditionalInfo
{
public ReleaseSourceType ReleaseSource { get; set; }
}
}

@ -300,8 +300,7 @@ namespace NzbDrone.Core.Download.Pending
List<Album> albums;
RemoteAlbum knownRemoteAlbum;
if (knownRemoteAlbums != null && knownRemoteAlbums.TryGetValue(release.Release.Title, out knownRemoteAlbum))
if (knownRemoteAlbums != null && knownRemoteAlbums.TryGetValue(release.Release.Title, out var knownRemoteAlbum))
{
albums = knownRemoteAlbum.Albums;
}
@ -315,6 +314,7 @@ namespace NzbDrone.Core.Download.Pending
Artist = artist,
Albums = albums,
ParsedAlbumInfo = release.ParsedAlbumInfo,
ReleaseSource = release.AdditionalInfo?.ReleaseSource ?? ReleaseSourceType.Unknown,
Release = release.Release
};

@ -9,6 +9,7 @@ namespace NzbDrone.Core.History
public class EntityHistory : ModelBase
{
public const string DOWNLOAD_CLIENT = "downloadClient";
public const string RELEASE_SOURCE = "releaseSource";
public EntityHistory()
{

@ -165,6 +165,7 @@ namespace NzbDrone.Core.History
history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString());
history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString());
history.Data.Add("CustomFormatScore", message.Album.CustomFormatScore.ToString());
history.Data.Add("ReleaseSource", message.Album.ReleaseSource.ToString());
if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace())
{

@ -17,6 +17,7 @@ namespace NzbDrone.Core.Parser.Model
public TorrentSeedConfiguration SeedConfiguration { get; set; }
public List<CustomFormat> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public ReleaseSourceType ReleaseSource { get; set; }
public RemoteAlbum()
{
@ -34,4 +35,14 @@ namespace NzbDrone.Core.Parser.Model
return Release.Title;
}
}
public enum ReleaseSourceType
{
Unknown = 0,
Rss = 1,
Search = 2,
UserInvokedSearch = 3,
InteractiveSearch = 4,
ReleasePush = 5
}
}

Loading…
Cancel
Save