use read locks wherever we can
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Steven Polley 2023-06-30 19:59:51 -06:00
parent 21220b692f
commit 120d61d1b6
1 changed files with 5 additions and 5 deletions

10
main.go
View File

@ -112,12 +112,12 @@ func updateROMCache() {
}
// skip already cached files
romCache.Lock()
romCache.RLock()
if _, ok := romCache.Cached[v.Name()]; ok {
romCache.Unlock()
romCache.RUnlock()
continue
}
romCache.Unlock()
romCache.RUnlock()
wg.Add(1)
go func(v fs.DirEntry) {
@ -188,9 +188,9 @@ func lineageOSROMListHandler(w http.ResponseWriter, r *http.Request) {
}
}()
romCache.Lock()
romCache.RLock()
httpResponseJSON := &HTTPResponseJSON{Response: romCache.ROMs}
romCache.Unlock()
romCache.RUnlock()
b, err := json.Marshal(httpResponseJSON)
if err != nil {