mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-13 00:23:59 -07:00
Commands are stored in memory and prevents duplicate jobs
This commit is contained in:
parent
a86c131761
commit
c917cdc0cc
16 changed files with 244 additions and 13 deletions
|
@ -4,6 +4,7 @@ using Nancy;
|
|||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Common.Messaging.Manager;
|
||||
|
||||
namespace NzbDrone.Api.Commands
|
||||
{
|
||||
|
@ -11,14 +12,16 @@ namespace NzbDrone.Api.Commands
|
|||
{
|
||||
private readonly IMessageAggregator _messageAggregator;
|
||||
private readonly IContainer _container;
|
||||
private readonly IManageCommands _commandManager;
|
||||
|
||||
public CommandModule(IMessageAggregator messageAggregator, IContainer container)
|
||||
public CommandModule(IMessageAggregator messageAggregator, IContainer container, IManageCommands commandManager)
|
||||
{
|
||||
_messageAggregator = messageAggregator;
|
||||
_container = container;
|
||||
_commandManager = commandManager;
|
||||
|
||||
Post["/"] = x => RunCommand(ReadResourceFromRequest());
|
||||
|
||||
Get["/"] = x => GetAllCommands();
|
||||
}
|
||||
|
||||
private Response RunCommand(CommandResource resource)
|
||||
|
@ -33,5 +36,10 @@ namespace NzbDrone.Api.Commands
|
|||
|
||||
return resource.AsResponse(HttpStatusCode.Created);
|
||||
}
|
||||
|
||||
private Response GetAllCommands()
|
||||
{
|
||||
return _commandManager.Items.AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue