skip initial deletion if init.mp4 doesn't exist

This commit is contained in:
Muaz Ahmad 2023-09-22 15:16:54 +05:00
parent c957c29188
commit 074222e8ac

View file

@ -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 {