Check author.Task() parameters

Check author.Task() parameters, and refuse tasks with empty name or type.
This commit is contained in:
Sybren A. Stüvel 2022-02-21 15:49:23 +01:00
parent e03e111603
commit 6a7545f334
2 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,8 @@ package job_compilers
* ***** END GPL LICENSE BLOCK ***** */ * ***** END GPL LICENSE BLOCK ***** */
import ( import (
"errors"
"strings"
"time" "time"
"github.com/dop251/goja" "github.com/dop251/goja"
@ -74,6 +76,15 @@ type AuthoredCommand struct {
type AuthoredCommandParameters map[string]interface{} type AuthoredCommandParameters map[string]interface{}
func (a *Author) Task(name string, taskType string) (*AuthoredTask, error) { func (a *Author) Task(name string, taskType string) (*AuthoredTask, error) {
name = strings.TrimSpace(name)
taskType = strings.TrimSpace(taskType)
if name == "" {
return nil, errors.New("author.Task(name, type): name is required")
}
if taskType == "" {
return nil, errors.New("author.Task(name, type): type is required")
}
at := AuthoredTask{ at := AuthoredTask{
uuid.New().String(), uuid.New().String(),
name, name,

View File

@ -120,7 +120,7 @@ function authorCreateVideoTask(settings, renderDir) {
const stem = path.stem(settings.filepath).replace('.flamenco', ''); const stem = path.stem(settings.filepath).replace('.flamenco', '');
const outfile = path.join(renderDir, `${stem}-${settings.frames}.mp4`); const outfile = path.join(renderDir, `${stem}-${settings.frames}.mp4`);
const task = author.Task('create-video'); const task = author.Task('create-video', 'ffmpeg');
const command = author.Command("create-video", { const command = author.Command("create-video", {
input_files: path.join(renderDir, `*${settings.output_file_extension}`), input_files: path.join(renderDir, `*${settings.output_file_extension}`),
output_file: outfile, output_file: outfile,