Skip to content

🎧 Your Personal Streaming Service

Schedule periodic scan before starting initial scan

Deluan8419a2a5d12e
diff --git a/cmd/root.go b/cmd/root.go
index 0a64539bf..d6680708c 100644
--- a/cmd/root.go
+++ b/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)) {