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 (
|
var (
|
||||||
lastPlayedCache []Song
|
lastPlayedCache []Song
|
||||||
lastPlayedCacheMutex sync.Mutex
|
lastPlayedCacheMutex sync.Mutex
|
||||||
|
isJustStarted bool = true
|
||||||
)
|
)
|
||||||
|
|
||||||
type IcecastStatusDTO struct {
|
type IcecastStatusDTO struct {
|
||||||
@ -203,6 +204,10 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
|||||||
select {
|
select {
|
||||||
case mask := <-pw.changed:
|
case mask := <-pw.changed:
|
||||||
if mask&syscall.IN_MODIFY > 0 {
|
if mask&syscall.IN_MODIFY > 0 {
|
||||||
|
if isJustStarted {
|
||||||
|
isJustStarted = false
|
||||||
|
break
|
||||||
|
}
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
if lastPlayedCache == nil {
|
if lastPlayedCache == nil {
|
||||||
lastPlayedCache = make([]Song, n)
|
lastPlayedCache = make([]Song, n)
|
||||||
|
Loading…
Reference in New Issue
Block a user