From bcda53f115e301da79ced7c422bca55b65a58153 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 29 Apr 2021 13:55:20 -0400 Subject: [PATCH] Less waiting for cache to be ready --- cmd/root.go | 4 ++-- core/cache_warmer.go | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d970c9a31..ead8f72a9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -59,7 +59,7 @@ func runNavidrome() { interval := conf.Server.ScanInterval if interval != 0 { - g.Add(startScanner(interval)) + g.Add(startPeriodicScan(interval)) } else { log.Warn("Periodic scan is DISABLED", "interval", interval) } @@ -115,7 +115,7 @@ func startSignaler() (func() error, func(err error)) { } } -func startScanner(interval time.Duration) (func() error, func(err error)) { +func startPeriodicScan(interval time.Duration) (func() error, func(err error)) { log.Info("Starting scanner", "interval", interval.String()) scanner := GetScanner() ctx, cancel := context.WithCancel(context.Background()) diff --git a/core/cache_warmer.go b/core/cache_warmer.go index d4b655a2c..47370a92d 100644 --- a/core/cache_warmer.go +++ b/core/cache_warmer.go @@ -47,13 +47,8 @@ func (w *warmer) AddAlbum(ctx context.Context, albumID string) { } func (w *warmer) waitForCacheReady(ctx context.Context) { - tick := time.NewTicker(time.Second) - defer tick.Stop() - for { - <-tick.C - if w.artworkCache.Ready(ctx) { - return - } + for !w.artworkCache.Ready(ctx) { + time.Sleep(time.Second) } }