summaryrefslogtreecommitdiff
path: root/utils/utils.go
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2020-03-29 21:11:32 +1000
committerJames Mills <prologic@shortcircuit.net.au>2020-03-29 21:11:32 +1000
commit107110183a036c7c9b0333cdc9b4c4a81916e321 (patch)
tree9f853171f25bea452d550bc62583292bda573fc0 /utils/utils.go
parent980a3edf63551b60a85307005cdb6f0380932d83 (diff)
Add support for unlimited timeouts for transcoding and thumbnail generation
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go11
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...)