Skip to content

Commit

Permalink
Fix segment removal logic broken if BaseURL set
Browse files Browse the repository at this point in the history
  • Loading branch information
Thor77 committed Jun 13, 2021
1 parent 4368ee3 commit 4531b46
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func removeOutdatedSegments(streamLogger *log.Entry, streamName string, playlist
currentSegments := make(map[string]struct{}, len(playlist.Segments))
for _, segment := range playlist.Segments {
if segment != nil {
currentSegments[segment.URI] = struct{}{}
currentSegments[path.Base(segment.URI)] = struct{}{}
}
}
// find (probably) segment files in current directory
Expand All @@ -32,7 +32,7 @@ func removeOutdatedSegments(streamLogger *log.Entry, streamName string, playlist
}
for _, segmentFile := range segmentFiles {
// check if file belongs to a playlist segment
if _, ok := currentSegments[segmentFile]; !ok {
if _, ok := currentSegments[path.Base(segmentFile)]; !ok {
if err := os.Remove(segmentFile); err != nil {
streamLogger.Errorln(err)
} else {
Expand Down Expand Up @@ -198,7 +198,7 @@ func publishHandler(conn *rtmp.Conn) {
// collect obsolete files
for _, segment := range playlist.Segments {
if segment != nil {
filesToRemove = append(filesToRemove, segment.URI)
filesToRemove = append(filesToRemove, path.Join(config.HLSDirectory, path.Base(segment.URI)))
}
}
filesToRemove = append(filesToRemove, playlistFileName)
Expand Down

0 comments on commit 4531b46

Please sign in to comment.