From 074222e8ac143fcba829c15464092be8d3ac3f79 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Fri, 22 Sep 2023 15:16:54 +0500 Subject: [PATCH] skip initial deletion if init.mp4 doesn't exist --- srt/stream_ids.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/srt/stream_ids.go b/srt/stream_ids.go index 7f598e1..f8df568 100644 --- a/srt/stream_ids.go +++ b/srt/stream_ids.go @@ -25,7 +25,10 @@ func CleanFiles(stream_key string, delay time.Duration) { time.Sleep(delay * time.Second) base_dir, _ := os.UserHomeDir() stream_dir := base_dir + "/live/" + stream_key - fileinfo, _ := os.Stat(stream_dir + "/init.mp4") + fileinfo, file_ok := os.Stat(stream_dir + "/init.mp4") + if file_ok != nil { + return + } if time.Now().Sub(fileinfo.ModTime()) > delay * time.Second { leftover_files, _ := filepath.Glob(stream_dir + "/*") for _, file := range leftover_files {