mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
feat(server): rename ScanSchedule conf to Scanner.Schedule, for consistency
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
f3cb85cb0d
commit
de37e0f720
2 changed files with 10 additions and 27 deletions
|
@ -137,18 +137,18 @@ func startServer(ctx context.Context) func() error {
|
||||||
// schedulePeriodicScan schedules a periodic scan of the music library, if configured.
|
// schedulePeriodicScan schedules a periodic scan of the music library, if configured.
|
||||||
func schedulePeriodicScan(ctx context.Context) func() error {
|
func schedulePeriodicScan(ctx context.Context) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
schedule := conf.Server.ScanSchedule
|
schedule := conf.Server.Scanner.Schedule
|
||||||
if schedule == "" {
|
if schedule == "" {
|
||||||
log.Warn(ctx, "Periodic scan is DISABLED")
|
log.Warn(ctx, "Periodic scan is DISABLED")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner := CreateScanner(ctx)
|
s := CreateScanner(ctx)
|
||||||
schedulerInstance := scheduler.GetInstance()
|
schedulerInstance := scheduler.GetInstance()
|
||||||
|
|
||||||
log.Info("Scheduling periodic scan", "schedule", schedule)
|
log.Info("Scheduling periodic scan", "schedule", schedule)
|
||||||
err := schedulerInstance.Add(schedule, func() {
|
err := schedulerInstance.Add(schedule, func() {
|
||||||
_, err := scanner.ScanAll(ctx, false)
|
_, err := s.ScanAll(ctx, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(ctx, "Error executing periodic scan", err)
|
log.Error(ctx, "Error executing periodic scan", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ type configOptions struct {
|
||||||
DbPath string
|
DbPath string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
LogFile string
|
LogFile string
|
||||||
ScanInterval time.Duration // Deprecated: Remove before release
|
|
||||||
ScanSchedule string
|
|
||||||
SessionTimeout time.Duration
|
SessionTimeout time.Duration
|
||||||
BaseURL string
|
BaseURL string
|
||||||
BasePath string
|
BasePath string
|
||||||
|
@ -128,6 +126,7 @@ type configOptions struct {
|
||||||
|
|
||||||
type scannerOptions struct {
|
type scannerOptions struct {
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
Schedule string
|
||||||
WatcherWait time.Duration
|
WatcherWait time.Duration
|
||||||
ScanOnStartup bool
|
ScanOnStartup bool
|
||||||
Extractor string
|
Extractor string
|
||||||
|
@ -360,25 +359,12 @@ func validatePlaylistsPath() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateScanSchedule() error {
|
func validateScanSchedule() error {
|
||||||
if Server.ScanInterval != -1 {
|
if Server.Scanner.Schedule == "0" || Server.Scanner.Schedule == "" {
|
||||||
log.Warn("ScanInterval is DEPRECATED. Please use ScanSchedule. See docs at https://navidrome.org/docs/usage/configuration-options/")
|
Server.Scanner.Schedule = ""
|
||||||
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 = ""
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
Server.ScanSchedule, err = validateSchedule(Server.ScanSchedule, "ScanSchedule")
|
Server.Scanner.Schedule, err = validateSchedule(Server.Scanner.Schedule, "Scanner.Schedule")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,10 +373,8 @@ func validateBackupSchedule() error {
|
||||||
Server.Backup.Schedule = ""
|
Server.Backup.Schedule = ""
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
Server.Backup.Schedule, err = validateSchedule(Server.Backup.Schedule, "BackupSchedule")
|
Server.Backup.Schedule, err = validateSchedule(Server.Backup.Schedule, "Backup.Schedule")
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +385,7 @@ func validateSchedule(schedule, field string) (string, error) {
|
||||||
c := cron.New()
|
c := cron.New()
|
||||||
id, err := c.AddFunc(schedule, func() {})
|
id, err := c.AddFunc(schedule, func() {})
|
||||||
if err != nil {
|
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 {
|
} else {
|
||||||
c.Remove(id)
|
c.Remove(id)
|
||||||
}
|
}
|
||||||
|
@ -423,8 +407,6 @@ func init() {
|
||||||
viper.SetDefault("port", 4533)
|
viper.SetDefault("port", 4533)
|
||||||
viper.SetDefault("unixsocketperm", "0660")
|
viper.SetDefault("unixsocketperm", "0660")
|
||||||
viper.SetDefault("sessiontimeout", consts.DefaultSessionTimeout)
|
viper.SetDefault("sessiontimeout", consts.DefaultSessionTimeout)
|
||||||
viper.SetDefault("scaninterval", -1)
|
|
||||||
viper.SetDefault("scanschedule", "0")
|
|
||||||
viper.SetDefault("baseurl", "")
|
viper.SetDefault("baseurl", "")
|
||||||
viper.SetDefault("tlscert", "")
|
viper.SetDefault("tlscert", "")
|
||||||
viper.SetDefault("tlskey", "")
|
viper.SetDefault("tlskey", "")
|
||||||
|
@ -490,6 +472,7 @@ func init() {
|
||||||
viper.SetDefault("jukebox.adminonly", true)
|
viper.SetDefault("jukebox.adminonly", true)
|
||||||
|
|
||||||
viper.SetDefault("scanner.enabled", true)
|
viper.SetDefault("scanner.enabled", true)
|
||||||
|
viper.SetDefault("scanner.schedule", "0")
|
||||||
viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor)
|
viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor)
|
||||||
viper.SetDefault("scanner.genreseparators", ";/,")
|
viper.SetDefault("scanner.genreseparators", ";/,")
|
||||||
viper.SetDefault("scanner.groupalbumreleases", false)
|
viper.SetDefault("scanner.groupalbumreleases", false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue