mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Fix race condition
This commit is contained in:
parent
2ccc5bc941
commit
83ae2ba3e6
2 changed files with 7 additions and 9 deletions
|
@ -158,13 +158,11 @@ func (s *scanner) RescanAll(ctx context.Context, fullRescan bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *scanner) getStatus(folder string) *scanStatus {
|
||||
func (s *scanner) getStatus(folder string) (scanStatus, bool) {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
if status, ok := s.status[folder]; ok {
|
||||
return status
|
||||
}
|
||||
return nil
|
||||
status, ok := s.status[folder]
|
||||
return *status, ok
|
||||
}
|
||||
|
||||
func (s *scanner) incStatusCounter(folder string, numFiles uint32) (totalFolders uint32, totalFiles uint32) {
|
||||
|
@ -199,8 +197,8 @@ func (s *scanner) setStatusEnd(folder string, lastUpdate time.Time) {
|
|||
}
|
||||
|
||||
func (s *scanner) Status(mediaFolder string) (*StatusInfo, error) {
|
||||
status := s.getStatus(mediaFolder)
|
||||
if status == nil {
|
||||
status, ok := s.getStatus(mediaFolder)
|
||||
if !ok {
|
||||
return nil, errors.New("mediaFolder not found")
|
||||
}
|
||||
return &StatusInfo{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue