mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Fine tune scan status behaviour
This commit is contained in:
parent
0e7163eb2c
commit
c09ba509b2
5 changed files with 76 additions and 26 deletions
|
@ -110,8 +110,22 @@ func (s *scanner) rescan(mediaFolder string, fullRescan bool) error {
|
|||
log.Debug("Scanning folder (full scan)", "folder", mediaFolder)
|
||||
}
|
||||
|
||||
progress := s.startProgressTracker(mediaFolder)
|
||||
defer close(progress)
|
||||
|
||||
err := folderScanner.Scan(log.NewContext(context.TODO()), lastModifiedSince, progress)
|
||||
if err != nil {
|
||||
log.Error("Error importing MediaFolder", "folder", mediaFolder, err)
|
||||
}
|
||||
|
||||
s.updateLastModifiedSince(mediaFolder, start)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *scanner) startProgressTracker(mediaFolder string) chan uint32 {
|
||||
progress := make(chan uint32, 100)
|
||||
go func() {
|
||||
s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: 0})
|
||||
defer func() {
|
||||
s.broker.SendMessage(&events.ScanStatus{Scanning: false, Count: int64(s.status[mediaFolder].count)})
|
||||
}()
|
||||
|
@ -127,15 +141,7 @@ func (s *scanner) rescan(mediaFolder string, fullRescan bool) error {
|
|||
s.broker.SendMessage(&events.ScanStatus{Scanning: true, Count: int64(total)})
|
||||
}
|
||||
}()
|
||||
|
||||
err := folderScanner.Scan(log.NewContext(context.TODO()), lastModifiedSince, progress)
|
||||
close(progress)
|
||||
if err != nil {
|
||||
log.Error("Error importing MediaFolder", "folder", mediaFolder, err)
|
||||
}
|
||||
|
||||
s.updateLastModifiedSince(mediaFolder, start)
|
||||
return err
|
||||
return progress
|
||||
}
|
||||
|
||||
func (s *scanner) RescanAll(fullRescan bool) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue