Describe the bug
In markEmailAsReadInStores() (main.go:738-745), the code iterates over and modifies m.folderEmails map without any synchronization. This map is also accessed from goroutines in saveFolderEmailsToCache() (line 630) and fetchFolderEmailsCmd() (line 2426+), creating a data race.
To reproduce
- Rapidly switch folders while emails are being fetched
- Run with
-race flag to detect
Expected behavior
Access to m.folderEmails should be protected by a mutex.
Describe the bug
In
markEmailAsReadInStores()(main.go:738-745), the code iterates over and modifiesm.folderEmailsmap without any synchronization. This map is also accessed from goroutines insaveFolderEmailsToCache()(line 630) andfetchFolderEmailsCmd()(line 2426+), creating a data race.To reproduce
-raceflag to detectExpected behavior
Access to
m.folderEmailsshould be protected by a mutex.