From 6a7545f3342175ebc4f2935c460b04005e80390f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 21 Feb 2022 15:49:23 +0100 Subject: [PATCH] Check author.Task() parameters Check author.Task() parameters, and refuse tasks with empty name or type. --- internal/manager/job_compilers/author.go | 11 +++++++++++ .../job_compilers/scripts/simple_blender_render.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/manager/job_compilers/author.go b/internal/manager/job_compilers/author.go index ec03da02..48bbdb15 100644 --- a/internal/manager/job_compilers/author.go +++ b/internal/manager/job_compilers/author.go @@ -21,6 +21,8 @@ package job_compilers * ***** END GPL LICENSE BLOCK ***** */ import ( + "errors" + "strings" "time" "github.com/dop251/goja" @@ -74,6 +76,15 @@ type AuthoredCommand struct { type AuthoredCommandParameters map[string]interface{} 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{ uuid.New().String(), name, diff --git a/internal/manager/job_compilers/scripts/simple_blender_render.js b/internal/manager/job_compilers/scripts/simple_blender_render.js index dae8818d..0da13b9a 100644 --- a/internal/manager/job_compilers/scripts/simple_blender_render.js +++ b/internal/manager/job_compilers/scripts/simple_blender_render.js @@ -120,7 +120,7 @@ function authorCreateVideoTask(settings, renderDir) { const stem = path.stem(settings.filepath).replace('.flamenco', ''); 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", { input_files: path.join(renderDir, `*${settings.output_file_extension}`), output_file: outfile,