Skip to content

Commit

Permalink
Merge pull request #209 from Dash-Industry-Forum/fix-create-track-dir
Browse files Browse the repository at this point in the history
fix: create track directory for init segment, if not already available
  • Loading branch information
tobbee authored Sep 11, 2024
2 parents 0ee2071 + 0d2f0a6 commit 10a898e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/cmaf-ingest-receiver/app/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (r *Receiver) SegmentHandlerFunc(w http.ResponseWriter, req *http.Request)
r.streams[stream.id()] = stream
err := os.MkdirAll(stream.trDir, 0755)
if err != nil {
slog.Error("Failed to create directory", "err", err)
http.Error(w, "Failed to create directory", http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -134,6 +135,10 @@ func (r *Receiver) SegmentHandlerFunc(w http.ResponseWriter, req *http.Request)
data := cd.Data // Used so that you can overwrite cd.Data when needed
if cd.IsInitSegment {
filePath := filepath.Join(stream.trDir, fmt.Sprintf("%s%s", "init", stream.ext))
err := os.MkdirAll(stream.trDir, 0755)
if err != nil {
return fmt.Errorf("failed to create dir: %w", err)
}
slog.Debug("Init segment received", "filePath", filePath)
ofh, err = os.Create(filePath)
if err != nil {
Expand Down

0 comments on commit 10a898e

Please sign in to comment.