From 05e89319550eba4cab0eb4ff693940c905591ea0 Mon Sep 17 00:00:00 2001 From: Liam Burnand Date: Tue, 20 Feb 2024 00:42:27 +0000 Subject: [PATCH] Adding better checking for streams --- forwarder/main.go | 2 +- recorder/main.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/forwarder/main.go b/forwarder/main.go index 447e525..09346f0 100644 --- a/forwarder/main.go +++ b/forwarder/main.go @@ -302,7 +302,7 @@ func (v *Views) run(config Config, interrupt chan os.Signal) { continue } case "status": - _, ok := v.cache.Get(fmt.Sprintf("%s_1", t.Unique)) + _, ok := v.cache.Get(fmt.Sprintf("%s_1_%s", t.Unique, finishChannelNameAppend)) if !ok { kill := v.errorResponse(fmt.Errorf("failed to get status, invalid unique: %s", t.Unique), c, m.ID) if kill { diff --git a/recorder/main.go b/recorder/main.go index 672803f..7df8507 100644 --- a/recorder/main.go +++ b/recorder/main.go @@ -306,6 +306,15 @@ func (v *Views) run(config Config, interrupt chan os.Signal) { continue } case "status": + _, ok := v.cache.Get(fmt.Sprintf("%s_%s", t.Unique, finishChannelNameAppend)) + if !ok { + kill := v.errorResponse(fmt.Errorf("failed to get status recorder, invalid unique: %s", t.Unique), c, m.ID) + if kill { + return + } + continue + } + out, err = v.status(t) if err != nil { kill := v.errorResponse(fmt.Errorf("failed to get status recorder: %w", err), c, m.ID) @@ -315,6 +324,15 @@ func (v *Views) run(config Config, interrupt chan os.Signal) { continue } case "stop": + _, ok := v.cache.Get(fmt.Sprintf("%s_%s", t.Unique, finishChannelNameAppend)) + if !ok { + kill := v.errorResponse(fmt.Errorf("failed to stop recorder, invalid unique: %s", t.Unique), c, m.ID) + if kill { + return + } + continue + } + err = v.stop(t) if err != nil { kill := v.errorResponse(fmt.Errorf("failed to stop recorder: %w", err), c, m.ID)