proper cleanup and permission check for the hls directory (#1167)

* check error on hls cleanup

* rm HLS directories before creating new ones

* don't mask the variable

* mv cleanupDirectory() to utils

* add user-friendly error messages
This commit is contained in:
Meisam
2021-07-08 21:35:53 +02:00
committed by GitHub
parent 0e0199aa98
commit a13e1e75e2
3 changed files with 18 additions and 12 deletions

View File

@ -226,3 +226,14 @@ func VerifyFFMpegPath(path string) error {
return nil
}
// Removes the directory and makes it again. Throws fatal error on failure.
func CleanupDirectory(path string) {
log.Traceln("Cleaning", path)
if err := os.RemoveAll(path); err != nil {
log.Fatalln("Unable to remove directory. Please check the ownership and permissions", err)
}
if err := os.MkdirAll(path, 0777); err != nil {
log.Fatalln("Unable to create directory. Please check the ownership and permissions", err)
}
}