Skip to content

Commit

Permalink
playback: in /list, always return 404 when there are no timespans
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jan 10, 2025
1 parent a598d12 commit 1d52a46
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 248 deletions.
6 changes: 6 additions & 0 deletions internal/playback/on_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,16 @@ func (s *Server) onList(ctx *gin.Context) {
firstEntry := entries[0]

// when start is placed in a gap between the first and second segment,
// or when there's no second segment,
// the first segment is erroneously included with a negative duration.
// remove it.
if firstEntry.Start.Add(time.Duration(firstEntry.Duration)).Before(*start) {
entries = entries[1:]

if len(entries) == 0 {
s.writeError(ctx, http.StatusNotFound, recordstore.ErrNoSegmentsFound)
return
}
} else if firstEntry.Start.Before(*start) {
entries[0].Duration -= listEntryDuration(start.Sub(firstEntry.Start))
entries[0].Start = *start
Expand Down
Loading

0 comments on commit 1d52a46

Please sign in to comment.