From 10048c671eb5a9c5bf9290782969c19060384f33 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 12 Mar 2023 03:53:09 +0400 Subject: [PATCH] Prevent reading latest song from a log right after a service started. --- internal/radio/icecast.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 2ad69b9..15bea43 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -24,6 +24,7 @@ const ( var ( lastPlayedCache []Song lastPlayedCacheMutex sync.Mutex + isJustStarted bool = true ) type IcecastStatusDTO struct { @@ -203,6 +204,10 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) { select { case mask := <-pw.changed: if mask&syscall.IN_MODIFY > 0 { + if isJustStarted { + isJustStarted = false + break + } lastPlayedCacheMutex.Lock() if lastPlayedCache == nil { lastPlayedCache = make([]Song, n)