diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 29c6285..308d1d7 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -5,6 +5,7 @@ import ( "dwelling-radio/pkg/watcher" "encoding/json" "io" + "log" "net/http" "os" "sync" @@ -185,8 +186,11 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) { if lastPlayedCache == nil { lastPlayedCache = make([]Song, 0, n) - if songs, err := icecastLastPlayedSongs(playlistPath, n); err == nil && len(songs) > 0 { + songs, err := icecastLastPlayedSongs(playlistPath, n) + if err == nil && len(songs) > 0 { lastPlayedCache = append(lastPlayedCache, songs...) + } else if err != nil { + log.Fatalln("Failed to retrieve last songs:", err) } } @@ -196,7 +200,8 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) { case mask := <-pw.changed: if mask&syscall.IN_MODIFY > 0 { lastPlayedCacheMutex.Lock() - if songs, err := icecastLastPlayedSongs(playlistPath, 1); err == nil && len(songs) > 0 { + songs, err := icecastLastPlayedSongs(playlistPath, 1) + if err == nil && len(songs) > 0 { CheckAndUpdateMostListenedSong(songs[0], currentlyPlaying) if currentlyPlaying.Time == "" { currentlyPlaying = songs[0] @@ -209,6 +214,8 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) { } currentlyPlaying = songs[0] } + } else if err != nil { + log.Println("Failed to retrieve last songs:", err) } lastPlayedCacheMutex.Unlock() } else if mask&syscall.IN_IGNORED > 0 {