Fix data race in scanner

This commit is contained in:
Deluan 2023-04-04 10:51:43 -04:00
parent bbb9461000
commit 61dd8d55ca

View file

@ -111,11 +111,13 @@ func (s *scanner) startProgressTracker(mediaFolder string) (chan uint32, context
go func() { go func() {
s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0}) s.broker.SendMessage(ctx, &events.ScanStatus{Scanning: true, Count: 0, FolderCount: 0})
defer func() { defer func() {
s.broker.SendMessage(ctx, &events.ScanStatus{ if status, ok := s.getStatus(mediaFolder); ok {
Scanning: false, s.broker.SendMessage(ctx, &events.ScanStatus{
Count: int64(s.status[mediaFolder].fileCount), Scanning: false,
FolderCount: int64(s.status[mediaFolder].folderCount), Count: int64(status.fileCount),
}) FolderCount: int64(status.folderCount),
})
}
}() }()
for { for {
select { select {