mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
Less waiting for cache to be ready
This commit is contained in:
parent
8a07bac2a2
commit
bcda53f115
2 changed files with 4 additions and 9 deletions
|
@ -59,7 +59,7 @@ func runNavidrome() {
|
||||||
|
|
||||||
interval := conf.Server.ScanInterval
|
interval := conf.Server.ScanInterval
|
||||||
if interval != 0 {
|
if interval != 0 {
|
||||||
g.Add(startScanner(interval))
|
g.Add(startPeriodicScan(interval))
|
||||||
} else {
|
} else {
|
||||||
log.Warn("Periodic scan is DISABLED", "interval", interval)
|
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())
|
log.Info("Starting scanner", "interval", interval.String())
|
||||||
scanner := GetScanner()
|
scanner := GetScanner()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
|
@ -47,13 +47,8 @@ func (w *warmer) AddAlbum(ctx context.Context, albumID string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *warmer) waitForCacheReady(ctx context.Context) {
|
func (w *warmer) waitForCacheReady(ctx context.Context) {
|
||||||
tick := time.NewTicker(time.Second)
|
for !w.artworkCache.Ready(ctx) {
|
||||||
defer tick.Stop()
|
time.Sleep(time.Second)
|
||||||
for {
|
|
||||||
<-tick.C
|
|
||||||
if w.artworkCache.Ready(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue