mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 04:27:37 +03:00
Add configuration for scan interval. Default 5 mins
This commit is contained in:
parent
f0ee41a8af
commit
182c0b5d5e
2 changed files with 13 additions and 6 deletions
|
@ -21,6 +21,7 @@ type sonic struct {
|
|||
ProbeCommand string `default:"ffmpeg %s -f ffmetadata"`
|
||||
PlsIgnoreFolders bool `default:"true"`
|
||||
PlsIgnoredPatterns string `default:"^iCloud;\\~"`
|
||||
ScanInterval string `default:"5m"`
|
||||
|
||||
// DevFlags. These are used to enable/disable debugging and incomplete features
|
||||
DevDisableAuthentication bool `default:"false"`
|
||||
|
|
|
@ -68,15 +68,21 @@ func (a *Server) initRoutes() {
|
|||
}
|
||||
|
||||
func (a *Server) initScanner() {
|
||||
interval, err := time.ParseDuration(conf.Sonic.ScanInterval)
|
||||
if err != nil {
|
||||
log.Error("Invalid interval specification. Using default of 5m", "conf", conf.Sonic.ScanInterval, err)
|
||||
interval = 5 * time.Minute
|
||||
} else {
|
||||
log.Info("Starting scanner", "interval", interval.String())
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(2 * time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
err := a.Scanner.RescanAll(false)
|
||||
if err != nil {
|
||||
log.Error("Error scanning media folder", "folder", conf.Sonic.MusicFolder, err)
|
||||
}
|
||||
err := a.Scanner.RescanAll(false)
|
||||
if err != nil {
|
||||
log.Error("Error scanning media folder", "folder", conf.Sonic.MusicFolder, err)
|
||||
}
|
||||
time.Sleep(interval)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue