skip initial deletion if init.mp4 doesn't exist
This commit is contained in:
parent
c957c29188
commit
074222e8ac
1 changed files with 4 additions and 1 deletions
|
@ -25,7 +25,10 @@ func CleanFiles(stream_key string, delay time.Duration) {
|
||||||
time.Sleep(delay * time.Second)
|
time.Sleep(delay * time.Second)
|
||||||
base_dir, _ := os.UserHomeDir()
|
base_dir, _ := os.UserHomeDir()
|
||||||
stream_dir := base_dir + "/live/" + stream_key
|
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 {
|
if time.Now().Sub(fileinfo.ModTime()) > delay * time.Second {
|
||||||
leftover_files, _ := filepath.Glob(stream_dir + "/*")
|
leftover_files, _ := filepath.Glob(stream_dir + "/*")
|
||||||
for _, file := range leftover_files {
|
for _, file := range leftover_files {
|
||||||
|
|
Loading…
Reference in a new issue