Breaking change: Add ScanSchedule, allows interval and cron based configurations.

See https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format for expression syntax.

`ScanInterval` will still work for the time being. The only situation it does not work is when you want to disable periodic scanning by setting `ScanInterval=0`. If you want to disable it, please set `ScanSchedule=""`

Closes #1085
This commit is contained in:
Deluan 2021-05-06 17:56:10 -04:00
parent 1d6aa70033
commit f8dbc41b6d
9 changed files with 164 additions and 30 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/persistence"
"github.com/navidrome/navidrome/scanner"
"github.com/navidrome/navidrome/scheduler"
"github.com/navidrome/navidrome/server"
"github.com/navidrome/navidrome/server/app"
"github.com/navidrome/navidrome/server/events"
@ -82,3 +83,22 @@ func createBroker() events.Broker {
events.NewBroker,
))
}
// Scheduler must be a Singleton
var (
onceScheduler sync.Once
schedulerInstance scheduler.Scheduler
)
func GetScheduler() scheduler.Scheduler {
onceScheduler.Do(func() {
schedulerInstance = createScheduler()
})
return schedulerInstance
}
func createScheduler() scheduler.Scheduler {
panic(wire.Build(
scheduler.New,
))
}