mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-15 03:30:39 +03:00
Schedule periodic scan before starting initial scan
This commit is contained in:
parent
71c2ed9922
commit
8419a2a5d1
12
cmd/root.go
12
cmd/root.go
@ -117,15 +117,9 @@ func startSignaler() (func() error, func(err error)) {
|
||||
}
|
||||
|
||||
func schedulePeriodicScan(schedule string) {
|
||||
time.Sleep(2 * time.Second) // Wait 2 seconds before the first scan
|
||||
scanner := GetScanner()
|
||||
scheduler := GetScheduler()
|
||||
|
||||
log.Info("Executing initial scan")
|
||||
if err := scanner.RescanAll(context.Background(), false); err != nil {
|
||||
log.Error("Error executing initial scan", err)
|
||||
}
|
||||
|
||||
log.Info("Scheduling periodic scan", "schedule", schedule)
|
||||
err := scheduler.Add(schedule, func() {
|
||||
_ = scanner.RescanAll(context.Background(), false)
|
||||
@ -133,6 +127,12 @@ func schedulePeriodicScan(schedule string) {
|
||||
if err != nil {
|
||||
log.Error("Error scheduling periodic scan", err)
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second) // Wait 2 seconds before the initial scan
|
||||
log.Info("Executing initial scan")
|
||||
if err := scanner.RescanAll(context.Background(), false); err != nil {
|
||||
log.Error("Error executing initial scan", err)
|
||||
}
|
||||
}
|
||||
|
||||
func startScheduler() (func() error, func(err error)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user