mirror of
https://github.com/Radarr/Radarr
synced 2025-12-27 18:54:03 +01:00
Inherit trigger from pushed command models
(cherry picked from commit 0bc4903954b955fce0c368ef7fd2a6f3761d6a93) Closes #10592
This commit is contained in:
parent
ab8a2d190e
commit
0049ccd39f
3 changed files with 7 additions and 8 deletions
|
|
@ -106,6 +106,8 @@ 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);
|
||||
|
||||
command.Trigger = trigger;
|
||||
|
||||
lock (_commandQueue)
|
||||
{
|
||||
var existingCommands = QueuedOrStarted(command.Name);
|
||||
|
|
@ -142,7 +144,6 @@ public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTi
|
|||
var command = GetCommand(commandName);
|
||||
command.LastExecutionTime = lastExecutionTime;
|
||||
command.LastStartTime = lastStartTime;
|
||||
command.Trigger = trigger;
|
||||
|
||||
return Push(command, priority, trigger);
|
||||
}
|
||||
|
|
@ -244,13 +245,13 @@ public void CleanCommands()
|
|||
_repo.Trim();
|
||||
}
|
||||
|
||||
private dynamic GetCommand(string commandName)
|
||||
private Command GetCommand(string commandName)
|
||||
{
|
||||
commandName = commandName.Split('.').Last();
|
||||
var commands = _knownTypes.GetImplementations(typeof(Command));
|
||||
var commandType = commands.Single(c => c.Name.Equals(commandName, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
return Json.Deserialize("{}", commandType);
|
||||
return Json.Deserialize("{}", commandType) as Command;
|
||||
}
|
||||
|
||||
private void Update(CommandModel command, CommandStatus status, string message)
|
||||
|
|
|
|||
|
|
@ -66,9 +66,8 @@ public ActionResult<CommandResource> StartCommand([FromBody] CommandResource com
|
|||
? CommandPriority.High
|
||||
: CommandPriority.Normal;
|
||||
|
||||
dynamic command = STJson.Deserialize(body, commandType);
|
||||
var command = STJson.Deserialize(body, commandType) as Command;
|
||||
|
||||
command.Trigger = CommandTrigger.Manual;
|
||||
command.SuppressMessages = !command.SendUpdatesToClient;
|
||||
command.SendUpdatesToClient = true;
|
||||
command.ClientUserAgent = Request.Headers["UserAgent"];
|
||||
|
|
|
|||
|
|
@ -274,9 +274,8 @@ public ActionResult<MovieResource> UpdateMovie([FromBody] MovieResource moviesRe
|
|||
{
|
||||
MovieId = movie.Id,
|
||||
SourcePath = sourcePath,
|
||||
DestinationPath = destinationPath,
|
||||
Trigger = CommandTrigger.Manual
|
||||
});
|
||||
DestinationPath = destinationPath
|
||||
}, trigger: CommandTrigger.Manual);
|
||||
}
|
||||
|
||||
var model = moviesResource.ToModel(movie);
|
||||
|
|
|
|||
Loading…
Reference in a new issue