0

Try to fix a race condition where a file is attempted to be moved and deleted at the same time

This commit is contained in:
Gabe Kangas 2020-06-17 17:52:47 -07:00
parent f20d8b3179
commit 0cb2ab396c
3 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,9 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os"
"path"
"strconv"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -94,11 +97,11 @@ func checkConfig(config Config) {
} }
if !fileExists(config.PrivateHLSPath) { if !fileExists(config.PrivateHLSPath) {
panic(fmt.Sprintf("%s does not exist.", config.PrivateHLSPath)) os.MkdirAll(path.Join(config.PrivateHLSPath, strconv.Itoa(0)), 0777)
} }
if !fileExists(config.PublicHLSPath) { if !fileExists(config.PublicHLSPath) {
panic(fmt.Sprintf("%s does not exist.", config.PublicHLSPath)) os.MkdirAll(path.Join(config.PublicHLSPath, strconv.Itoa(0)), 0777)
} }
if !fileExists(config.FFMpegPath) { if !fileExists(config.FFMpegPath) {

View File

@ -25,6 +25,7 @@ func main() {
log.StandardLogger().Printf("Owncast v%s/%s (%s)", BuildVersion, BuildType, GitCommit) log.StandardLogger().Printf("Owncast v%s/%s (%s)", BuildVersion, BuildType, GitCommit)
checkConfig(configuration) checkConfig(configuration)
stats = getSavedStats() stats = getSavedStats()
stats.Setup() stats.Setup()
@ -38,7 +39,6 @@ func main() {
if usingExternalStorage { if usingExternalStorage {
storage.Setup(configuration) storage.Setup(configuration)
// hlsDirectoryPath = configuration.PrivateHLSPath
go monitorVideoContent(configuration.PrivateHLSPath, configuration, storage) go monitorVideoContent(configuration.PrivateHLSPath, configuration, storage)
} }

View File

@ -55,6 +55,8 @@ func copy(src, dst string) {
} }
func resetDirectories(configuration Config) { func resetDirectories(configuration Config) {
log.Println("Resetting file directories to a clean slate.")
// Wipe the public, web-accessible hls data directory // Wipe the public, web-accessible hls data directory
os.RemoveAll(configuration.PublicHLSPath) os.RemoveAll(configuration.PublicHLSPath)
os.RemoveAll(configuration.PrivateHLSPath) os.RemoveAll(configuration.PrivateHLSPath)