fix(scanner): make activity panel update rate configurable

This commit is contained in:
Deluan 2024-09-30 12:06:17 -04:00 committed by Joe Stump
parent 3a0ddd5fc4
commit a5c3796e6e
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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() {