From 6439075f36222ea93b73764a059e96ef6d70366f Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 11 Jun 2020 21:15:29 -0700 Subject: [PATCH] Spawn go routine for saving segment --- playlistMonitor.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playlistMonitor.go b/playlistMonitor.go index c9b5fdb77..783080e73 100644 --- a/playlistMonitor.go +++ b/playlistMonitor.go @@ -96,7 +96,13 @@ func monitorVideoContent(pathToMonitor string, configuration Config, storage Chu writePlaylist(playlistString, path.Join(configuration.PublicHLSPath, relativePath)) } else if filepath.Ext(event.Path) == ".ts" { segment := getSegmentFromPath(event.Path) - newObjectPath := storage.Save(path.Join(configuration.PrivateHLSPath, segment.RelativeUploadPath)) + + newObjectPathChannel := make(chan string, 1) + go func() { + newObjectPath := storage.Save(path.Join(configuration.PrivateHLSPath, segment.RelativeUploadPath)) + newObjectPathChannel <- newObjectPath + }() + newObjectPath := <-newObjectPathChannel segment.RemoteID = newObjectPath // fmt.Println("Uploaded", segment.RelativeUploadPath, "as", newObjectPath)