diff --git a/cmd/root.go b/cmd/root.go index e63b52bdd..0ef1e7601 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -137,18 +137,18 @@ func startServer(ctx context.Context) func() error { // schedulePeriodicScan schedules a periodic scan of the music library, if configured. func schedulePeriodicScan(ctx context.Context) func() error { return func() error { - schedule := conf.Server.ScanSchedule + schedule := conf.Server.Scanner.Schedule if schedule == "" { log.Warn(ctx, "Periodic scan is DISABLED") return nil } - scanner := CreateScanner(ctx) + s := CreateScanner(ctx) schedulerInstance := scheduler.GetInstance() log.Info("Scheduling periodic scan", "schedule", schedule) err := schedulerInstance.Add(schedule, func() { - _, err := scanner.ScanAll(ctx, false) + _, err := s.ScanAll(ctx, false) if err != nil { log.Error(ctx, "Error executing periodic scan", err) } diff --git a/conf/configuration.go b/conf/configuration.go index e342192e9..32d0e2e78 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -29,8 +29,6 @@ type configOptions struct { DbPath string LogLevel string LogFile string - ScanInterval time.Duration // Deprecated: Remove before release - ScanSchedule string SessionTimeout time.Duration BaseURL string BasePath string @@ -128,6 +126,7 @@ type configOptions struct { type scannerOptions struct { Enabled bool + Schedule string WatcherWait time.Duration ScanOnStartup bool Extractor string @@ -360,25 +359,12 @@ func validatePlaylistsPath() error { } func validateScanSchedule() error { - if Server.ScanInterval != -1 { - log.Warn("ScanInterval is DEPRECATED. Please use ScanSchedule. See docs at https://navidrome.org/docs/usage/configuration-options/") - if Server.ScanSchedule != "@every 1m" { - log.Error("You cannot specify both ScanInterval and ScanSchedule, ignoring ScanInterval") - } else { - if Server.ScanInterval == 0 { - Server.ScanSchedule = "" - } else { - Server.ScanSchedule = fmt.Sprintf("@every %s", Server.ScanInterval) - } - log.Warn("Setting ScanSchedule", "schedule", Server.ScanSchedule) - } - } - if Server.ScanSchedule == "0" || Server.ScanSchedule == "" { - Server.ScanSchedule = "" + if Server.Scanner.Schedule == "0" || Server.Scanner.Schedule == "" { + Server.Scanner.Schedule = "" return nil } var err error - Server.ScanSchedule, err = validateSchedule(Server.ScanSchedule, "ScanSchedule") + Server.Scanner.Schedule, err = validateSchedule(Server.Scanner.Schedule, "Scanner.Schedule") return err } @@ -387,10 +373,8 @@ func validateBackupSchedule() error { Server.Backup.Schedule = "" return nil } - var err error - Server.Backup.Schedule, err = validateSchedule(Server.Backup.Schedule, "BackupSchedule") - + Server.Backup.Schedule, err = validateSchedule(Server.Backup.Schedule, "Backup.Schedule") return err } @@ -401,7 +385,7 @@ func validateSchedule(schedule, field string) (string, error) { c := cron.New() id, err := c.AddFunc(schedule, func() {}) if err != nil { - log.Error(fmt.Sprintf("Invalid %s. Please read format spec at https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format", field), "schedule", field, err) + log.Error(fmt.Sprintf("Invalid %s. Please read format spec at https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format", field), "schedule", schedule, err) } else { c.Remove(id) } @@ -423,8 +407,6 @@ func init() { viper.SetDefault("port", 4533) viper.SetDefault("unixsocketperm", "0660") viper.SetDefault("sessiontimeout", consts.DefaultSessionTimeout) - viper.SetDefault("scaninterval", -1) - viper.SetDefault("scanschedule", "0") viper.SetDefault("baseurl", "") viper.SetDefault("tlscert", "") viper.SetDefault("tlskey", "") @@ -490,6 +472,7 @@ func init() { viper.SetDefault("jukebox.adminonly", true) viper.SetDefault("scanner.enabled", true) + viper.SetDefault("scanner.schedule", "0") viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor) viper.SetDefault("scanner.genreseparators", ";/,") viper.SetDefault("scanner.groupalbumreleases", false)