🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Show folders scanned instead of files scanned
Deluana1dcb9a4e370
diff --git a/scanner/scanner.go b/scanner/scanner.goindex 64cc2b1c6..e5bb5d7a4 100644--- a/scanner/scanner.go+++ b/scanner/scanner.go@@ -6,7 +6,6 @@ import ("fmt""strconv""sync"- "sync/atomic""time""github.com/deluan/navidrome/core"@@ -29,6 +28,7 @@ type StatusInfo struct {Scanning boolLastScan time.TimeCount uint32+ FolderCount uint32}var (@@ -54,9 +54,10 @@ type scanner struct {}type scanStatus struct {- active bool- count uint32- lastUpdate time.Time+ active bool+ fileCount uint32+ folderCount uint32+ lastUpdate time.Time}func New(ds model.DataStore, cacheWarmer core.CacheWarmer, broker events.Broker) Scanner {@@ -125,9 +126,13 @@ func (s *scanner) rescan(mediaFolder string, fullRescan bool) error {func (s *scanner) startProgressTracker(mediaFolder string) chan uint32 {progress := make(chan uint32, 100)go func() {- s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: 0})+ s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0})defer func() {- s.broker.SendMessage(&events.ScanStatus{Scanning: false, Count: int64(s.status[mediaFolder].count)})+ s.broker.SendMessage(&events.ScanStatus{+ Scanning: false,+ Count: int64(s.status[mediaFolder].fileCount),+ FolderCount: int64(s.status[mediaFolder].folderCount),+ })}()for {count, more := <-progress@@ -137,8 +142,12 @@ func (s *scanner) startProgressTracker(mediaFolder string) chan uint32 {if count == 0 {continue}- total := atomic.AddUint32(&s.status[mediaFolder].count, count)- s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: int64(total)})+ totalFolders, totalFiles := s.incStatusCounter(mediaFolder, count)+ s.broker.SendMessage(&events.ScanStatus{+ Scanning: true,+ Count: int64(totalFiles),+ FolderCount: int64(totalFolders),+ })}}()return progress@@ -174,12 +183,25 @@ func (s *scanner) getStatus(folder string) *scanStatus {return nil}+func (s *scanner) incStatusCounter(folder string, numFiles uint32) (totalFolders uint32, totalFiles uint32) {+ s.lock.Lock()+ defer s.lock.Unlock()+ if status, ok := s.status[folder]; ok {+ status.fileCount += numFiles+ status.folderCount+++ totalFolders = status.folderCount+ totalFiles = status.fileCount+ }+ return+}+func (s *scanner) setStatusStart(folder string) {s.lock.Lock()defer s.lock.Unlock()if status, ok := s.status[folder]; ok {status.active = true- status.count = 0+ status.fileCount = 0+ status.folderCount = 0}}@@ -205,7 +227,8 @@ func (s *scanner) Status(mediaFolder string) (*StatusInfo, error) {MediaFolder: mediaFolder,Scanning: status.active,LastScan: status.lastUpdate,- Count: status.count,+ Count: status.fileCount,+ FolderCount: status.folderCount,}, nil}@@ -234,9 +257,10 @@ func (s *scanner) loadFolders() {log.Info("Configuring Media Folder", "name", f.Name, "path", f.Path)s.folders[f.Path] = s.newScanner(f)s.status[f.Path] = &scanStatus{- active: false,- count: 0,- lastUpdate: s.getLastModifiedSince(f.Path),+ active: false,+ fileCount: 0,+ folderCount: 0,+ lastUpdate: s.getLastModifiedSince(f.Path),}}}diff --git a/server/events/events.go b/server/events/events.goindex 12db34b32..edeaf9e1a 100644--- a/server/events/events.go+++ b/server/events/events.go@@ -7,8 +7,9 @@ type Event interface {}type ScanStatus struct {- Scanning bool `json:"scanning"`- Count int64 `json:"count"`+ Scanning bool `json:"scanning"`+ Count int64 `json:"count"`+ FolderCount int64 `json:"folderCount"`}func (s ScanStatus) EventName() string { return "scanStatus" }diff --git a/server/subsonic/library_scanning.go b/server/subsonic/library_scanning.goindex 21bdc793b..928d341f0 100644--- a/server/subsonic/library_scanning.go+++ b/server/subsonic/library_scanning.go@@ -30,9 +30,10 @@ func (c *LibraryScanningController) GetScanStatus(w http.ResponseWriter, r *http}response := newResponse()response.ScanStatus = &responses.ScanStatus{- Scanning: status.Scanning,- Count: int64(status.Count),- LastScan: &status.LastScan,+ Scanning: status.Scanning,+ Count: int64(status.Count),+ FolderCount: int64(status.FolderCount),+ LastScan: &status.LastScan,}return response, nil}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSONindex bbbbc5224..3a4da64ad 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":true,"count":123,"lastScan":"2006-01-02T15:04:00Z"}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":true,"count":456,"folderCount":123,"lastScan":"2006-01-02T15:04:00Z"}}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XMLindex 826724e9e..8a88d16d0 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus with data should match .XML@@ -1 +1 @@-<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><scanStatus scanning="true" count="123" lastScan="2006-01-02T15:04:00Z"></scanStatus></subsonic-response>+<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><scanStatus scanning="true" count="456" folderCount="123" lastScan="2006-01-02T15:04:00Z"></scanStatus></subsonic-response>diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSONindex 1aa0cf513..cacbff46c 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":false,"count":0}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","scanStatus":{"scanning":false,"count":0,"folderCount":0}}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XMLindex 7add568de..b8f0d866e 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses ScanStatus without data should match .XML@@ -1 +1 @@-<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><scanStatus scanning="false" count="0"></scanStatus></subsonic-response>+<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><scanStatus scanning="false" count="0" folderCount="0"></scanStatus></subsonic-response>diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.goindex c8f848e0d..335821397 100644--- a/server/subsonic/responses/responses.go+++ b/server/subsonic/responses/responses.go@@ -341,7 +341,8 @@ type Bookmarks struct {}type ScanStatus struct {- Scanning bool `xml:"scanning,attr" json:"scanning"`- Count int64 `xml:"count,attr" json:"count"`- LastScan *time.Time `xml:"lastScan,attr,omitempty" json:"lastScan,omitempty"`+ Scanning bool `xml:"scanning,attr" json:"scanning"`+ Count int64 `xml:"count,attr" json:"count"`+ FolderCount int64 `xml:"folderCount,attr" json:"folderCount"`+ LastScan *time.Time `xml:"lastScan,attr,omitempty" json:"lastScan,omitempty"`}diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.goindex bc6804469..8fce11a1a 100644--- a/server/subsonic/responses/responses_test.go+++ b/server/subsonic/responses/responses_test.go@@ -546,9 +546,10 @@ var _ = Describe("Responses", func() {BeforeEach(func() {t, _ := time.Parse(time.RFC822, time.RFC822)response.ScanStatus = &ScanStatus{- Scanning: true,- Count: 123,- LastScan: &t,+ Scanning: true,+ FolderCount: 123,+ Count: 456,+ LastScan: &t,}})It("should match .XML", func() {diff --git a/ui/src/layout/ActivityPanel.js b/ui/src/layout/ActivityPanel.jsindex 60d3d2cea..d950a5938 100644--- a/ui/src/layout/ActivityPanel.js+++ b/ui/src/layout/ActivityPanel.js@@ -127,7 +127,7 @@ const ActivityPanel = () => {{translate('activity.totalScanned')}:</Box><Box component="span" flex={1}>- {scanStatus.count}+ {scanStatus.folderCount || '-'}</Box></Box></CardContent>diff --git a/ui/src/reducers/activityReducer.js b/ui/src/reducers/activityReducer.jsindex 12abb98f2..aa57f8882 100644--- a/ui/src/reducers/activityReducer.js+++ b/ui/src/reducers/activityReducer.js@@ -1,6 +1,8 @@import { EVENT_SCAN_STATUS, EVENT_SERVER_START } from '../actions'-const defaultState = { scanStatus: { scanning: false, count: 0 } }+const defaultState = {+ scanStatus: { scanning: false, folderCount: 0, count: 0 },+}export const activityReducer = (previousState = {