From 107110183a036c7c9b0333cdc9b4c4a81916e321 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sun, 29 Mar 2020 21:11:32 +1000 Subject: Add support for unlimited timeouts for transcoding and thumbnail generation --- utils/utils.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/utils.go b/utils/utils.go index f80834c..d58c6c2 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -57,7 +57,16 @@ func CmdExists(cmd string) bool { // RunCmd ... func RunCmd(timeout int, command string, args ...string) error { - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second) + var ( + ctx context.Context + cancel context.CancelFunc + ) + + if timeout > 0 { + ctx, cancel = context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second) + } else { + ctx, cancel = context.WithCancel(context.Background()) + } defer cancel() cmd := exec.CommandContext(ctx, command, args...) -- cgit v1.2.3