mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-25 06:57:08 -04:00
Skip unknown/removed commands still queued in the database
This commit is contained in:
parent
8d2d19d17b
commit
1fc49f2aa1
5 changed files with 52 additions and 3 deletions
|
@ -1,7 +1,10 @@
|
||||||
|
using System.Data;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Datastore.Converters;
|
using NzbDrone.Core.Datastore.Converters;
|
||||||
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Movies.Commands;
|
using NzbDrone.Core.Movies.Commands;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
@ -42,6 +45,14 @@ namespace NzbDrone.Core.Test.Datastore.Converters
|
||||||
Subject.Parse(data).Should().BeOfType<RefreshMovieCommand>();
|
Subject.Parse(data).Should().BeOfType<RefreshMovieCommand>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_unknown_command_when_getting_json_from_db()
|
||||||
|
{
|
||||||
|
var data = "{\"name\": \"EnsureMediaCovers\"}";
|
||||||
|
|
||||||
|
Subject.Parse(data).Should().BeOfType<UnknownCommand>();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_null_for_null_value_when_getting_from_db()
|
public void should_return_null_for_null_value_when_getting_from_db()
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,11 @@ namespace NzbDrone.Core.Datastore.Converters
|
||||||
|
|
||||||
if (impType == null)
|
if (impType == null)
|
||||||
{
|
{
|
||||||
throw new CommandNotFoundException(contract);
|
var result = JsonSerializer.Deserialize<UnknownCommand>(stringValue, SerializerSettings);
|
||||||
|
|
||||||
|
result.ContractName = contract;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Command)JsonSerializer.Deserialize(stringValue, impType, SerializerSettings);
|
return (Command)JsonSerializer.Deserialize(stringValue, impType, SerializerSettings);
|
||||||
|
|
|
@ -71,8 +71,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var handlerContract = typeof(IExecute<>).MakeGenericType(command.GetType());
|
handler = (IExecute<TCommand>)_serviceFactory.Build(typeof(IExecute<TCommand>));
|
||||||
handler = (IExecute<TCommand>)_serviceFactory.Build(handlerContract);
|
|
||||||
|
|
||||||
_logger.Trace("{0} -> {1}", command.GetType().Name, handler.GetType().Name);
|
_logger.Trace("{0} -> {1}", command.GetType().Name, handler.GetType().Name);
|
||||||
|
|
||||||
|
|
11
src/NzbDrone.Core/Messaging/Commands/UnknownCommand.cs
Normal file
11
src/NzbDrone.Core/Messaging/Commands/UnknownCommand.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
namespace NzbDrone.Core.Messaging.Commands
|
||||||
|
{
|
||||||
|
public class UnknownCommand : Command
|
||||||
|
{
|
||||||
|
public override bool SendUpdatesToClient => false;
|
||||||
|
|
||||||
|
public override string CompletionMessage => "Skipped";
|
||||||
|
|
||||||
|
public string ContractName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Messaging.Commands
|
||||||
|
{
|
||||||
|
public class UnknownCommandExecutor : IExecute<UnknownCommand>
|
||||||
|
{
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public UnknownCommandExecutor(Logger logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(UnknownCommand message)
|
||||||
|
{
|
||||||
|
_logger.Debug("Ignoring unknown command {0}", message.ContractName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue