mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Plugin API improvements (#4603)
* Accept plain map for runPluginTask * Support running plugin task without task name * Add interface to run plugin operations * Update RunPluginTask client mutation
This commit is contained in:
@@ -9,7 +9,13 @@ import (
|
||||
"github.com/stashapp/stash/pkg/plugin"
|
||||
)
|
||||
|
||||
func (s *Manager) RunPluginTask(ctx context.Context, pluginID string, taskName string, args []*plugin.PluginArgInput) int {
|
||||
func (s *Manager) RunPluginTask(
|
||||
ctx context.Context,
|
||||
pluginID string,
|
||||
taskName *string,
|
||||
description *string,
|
||||
args plugin.OperationInput,
|
||||
) int {
|
||||
j := job.MakeJobExec(func(jobCtx context.Context, progress *job.Progress) {
|
||||
pluginProgress := make(chan float64)
|
||||
task, err := s.PluginCache.CreateTask(ctx, pluginID, taskName, args, pluginProgress)
|
||||
@@ -56,5 +62,12 @@ func (s *Manager) RunPluginTask(ctx context.Context, pluginID string, taskName s
|
||||
}
|
||||
})
|
||||
|
||||
return s.JobManager.Add(ctx, fmt.Sprintf("Running plugin task: %s", taskName), j)
|
||||
displayName := pluginID
|
||||
if taskName != nil {
|
||||
displayName = *taskName
|
||||
}
|
||||
if description != nil {
|
||||
displayName = *description
|
||||
}
|
||||
return s.JobManager.Add(ctx, fmt.Sprintf("Running plugin task: %s", displayName), j)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user