diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-29 21:11:32 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-29 21:11:32 +1000 |
| commit | 107110183a036c7c9b0333cdc9b4c4a81916e321 (patch) | |
| tree | 9f853171f25bea452d550bc62583292bda573fc0 /utils | |
| parent | 980a3edf63551b60a85307005cdb6f0380932d83 (diff) | |
Add support for unlimited timeouts for transcoding and thumbnail generation
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/utils.go | 11 |
1 files changed, 10 insertions, 1 deletions
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...) |
