Prevent reading latest song from a log right after a service started.
This commit is contained in:
parent
e73a9a3b12
commit
10048c671e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user