fix(scanner): make activity panel update rate configurable

This commit is contained in:
Deluan 2024-09-30 12:06:17 -04:00
parent 06c9c1e64a
commit 92a1f19271
2 changed files with 4 additions and 1 deletions

View file

@ -100,6 +100,7 @@ type configOptions struct {
DevAutoCreateAdminPassword string DevAutoCreateAdminPassword string
DevAutoLoginUsername string DevAutoLoginUsername string
DevActivityPanel bool DevActivityPanel bool
DevActivityPanelUpdateRate time.Duration
DevSidebarPlaylists bool DevSidebarPlaylists bool
DevEnableBufferedScrobble bool DevEnableBufferedScrobble bool
DevShowArtistPage bool DevShowArtistPage bool
@ -370,6 +371,7 @@ func init() {
viper.SetDefault("devautocreateadminpassword", "") viper.SetDefault("devautocreateadminpassword", "")
viper.SetDefault("devautologinusername", "") viper.SetDefault("devautologinusername", "")
viper.SetDefault("devactivitypanel", true) viper.SetDefault("devactivitypanel", true)
viper.SetDefault("devactivitypanelupdaterate", 300*time.Millisecond)
viper.SetDefault("enablesharing", false) viper.SetDefault("enablesharing", false)
viper.SetDefault("shareurl", "") viper.SetDefault("shareurl", "")
viper.SetDefault("defaultdownloadableshare", false) viper.SetDefault("defaultdownloadableshare", false)

View file

@ -7,6 +7,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/core" "github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/core/artwork" "github.com/navidrome/navidrome/core/artwork"
"github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/log"
@ -119,7 +120,7 @@ func (s *scanner) startProgressTracker(library string) (chan uint32, context.Can
// Must be a new context (not the one passed to the scan method) to allow broadcasting the scan status to all clients // Must be a new context (not the one passed to the scan method) to allow broadcasting the scan status to all clients
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
progress := make(chan uint32, 1000) progress := make(chan uint32, 1000)
limiter := rate.Sometimes{Every: 10} limiter := rate.Sometimes{Interval: conf.Server.DevActivityPanelUpdateRate}
go func() { go func() {
s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0}) s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0})
defer func() { defer func() {