Simplify HLS storage paths (#1393)

* Remove private vs public HLS paths and add a HLS controller. Closes #875

* Use http.ServeFile instead
This commit is contained in:
Gabe Kangas
2021-09-12 11:32:42 -07:00
committed by GitHub
parent b92ad00926
commit 1b053ffd1b
11 changed files with 71 additions and 67 deletions

View File

@@ -1,14 +1,12 @@
package storageproviders
import (
"path/filepath"
"time"
log "github.com/sirupsen/logrus"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core/transcoder"
"github.com/owncast/owncast/utils"
)
// LocalStorage represents an instance of the local storage provider for HLS video.
@@ -25,7 +23,7 @@ func (s *LocalStorage) Setup() error {
_onlineCleanupTicker = time.NewTicker(1 * time.Minute)
go func() {
for range _onlineCleanupTicker.C {
transcoder.CleanupOldContent(config.PublicHLSStoragePath)
transcoder.CleanupOldContent(config.HLSStoragePath)
}
}()
return nil
@@ -55,15 +53,5 @@ func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) {
// Save will save a local filepath using the storage provider.
func (s *LocalStorage) Save(filePath string, retryCount int) (string, error) {
newPath := ""
// This is a hack
if filePath == "hls/stream.m3u8" {
newPath = filepath.Join(config.PublicHLSStoragePath, filepath.Base(filePath))
} else {
newPath = filepath.Join(config.WebRoot, filePath)
}
err := utils.Copy(filePath, newPath)
return newPath, err
return filePath, nil
}

View File

@@ -199,7 +199,7 @@ func (s *S3Storage) rewriteRemotePlaylist(filePath string) error {
item.URI = s.host + filepath.Join("/hls", item.URI)
}
publicPath := filepath.Join(config.PublicHLSStoragePath, filepath.Base(filePath))
publicPath := filepath.Join(config.HLSStoragePath, filepath.Base(filePath))
newPlaylist := p.String()