1
0

Prevent reading latest song from a log right after a service started.

This commit is contained in:
Alexander Andreev 2023-03-12 03:53:09 +04:00
parent e73a9a3b12
commit 10048c671e
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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)