mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 05:25:10 +00:00
Fixed timing issue allowing multiple instances of the same command to be queued
This commit is contained in:
parent
b7aa945eae
commit
9f6e3d388b
1 changed files with 26 additions and 23 deletions
|
@ -100,32 +100,35 @@ public CommandModel Push<TCommand>(TCommand command, CommandPriority priority =
|
|||
_logger.Trace("Publishing {0}", command.Name);
|
||||
_logger.Trace("Checking if command is queued or started: {0}", command.Name);
|
||||
|
||||
var existingCommands = QueuedOrStarted(command.Name);
|
||||
var existing = existingCommands.SingleOrDefault(c => CommandEqualityComparer.Instance.Equals(c.Body, command));
|
||||
|
||||
if (existing != null)
|
||||
lock (_commandQueue)
|
||||
{
|
||||
_logger.Trace("Command is already in progress: {0}", command.Name);
|
||||
var existingCommands = QueuedOrStarted(command.Name);
|
||||
var existing = existingCommands.FirstOrDefault(c => CommandEqualityComparer.Instance.Equals(c.Body, command));
|
||||
|
||||
return existing;
|
||||
if (existing != null)
|
||||
{
|
||||
_logger.Trace("Command is already in progress: {0}", command.Name);
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
var commandModel = new CommandModel
|
||||
{
|
||||
Name = command.Name,
|
||||
Body = command,
|
||||
QueuedAt = DateTime.UtcNow,
|
||||
Trigger = trigger,
|
||||
Priority = priority,
|
||||
Status = CommandStatus.Queued
|
||||
};
|
||||
|
||||
_logger.Trace("Inserting new command: {0}", commandModel.Name);
|
||||
|
||||
_repo.Insert(commandModel);
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
return commandModel;
|
||||
}
|
||||
|
||||
var commandModel = new CommandModel
|
||||
{
|
||||
Name = command.Name,
|
||||
Body = command,
|
||||
QueuedAt = DateTime.UtcNow,
|
||||
Trigger = trigger,
|
||||
Priority = priority,
|
||||
Status = CommandStatus.Queued
|
||||
};
|
||||
|
||||
_logger.Trace("Inserting new command: {0}", commandModel.Name);
|
||||
|
||||
_repo.Insert(commandModel);
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
return commandModel;
|
||||
}
|
||||
|
||||
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
|
||||
|
|
Loading…
Reference in a new issue