From a5c3796e6e7013172d1c1780f66c1482a43f4e90 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 30 Sep 2024 12:06:17 -0400 Subject: [PATCH] fix(scanner): make activity panel update rate configurable --- conf/configuration.go | 2 ++ scanner/scanner.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/configuration.go b/conf/configuration.go index 0f64bb571..a3a974ee8 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -101,6 +101,7 @@ type configOptions struct { DevAutoCreateAdminPassword string DevAutoLoginUsername string DevActivityPanel bool + DevActivityPanelUpdateRate time.Duration DevSidebarPlaylists bool DevEnableBufferedScrobble bool DevShowArtistPage bool @@ -389,6 +390,7 @@ func init() { viper.SetDefault("devautocreateadminpassword", "") viper.SetDefault("devautologinusername", "") viper.SetDefault("devactivitypanel", true) + viper.SetDefault("devactivitypanelupdaterate", 300*time.Millisecond) viper.SetDefault("enablesharing", false) viper.SetDefault("shareurl", "") viper.SetDefault("defaultdownloadableshare", false) diff --git a/scanner/scanner.go b/scanner/scanner.go index 4bcf8658f..1e7dee417 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -7,6 +7,7 @@ import ( "sync" "time" + "github.com/navidrome/navidrome/conf" "github.com/navidrome/navidrome/core" "github.com/navidrome/navidrome/core/artwork" "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 ctx, cancel := context.WithCancel(context.Background()) progress := make(chan uint32, 1000) - limiter := rate.Sometimes{Every: 10} + limiter := rate.Sometimes{Interval: conf.Server.DevActivityPanelUpdateRate} go func() { s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0}) defer func() {