diff --git a/main.go b/main.go index 2d770b5..5e6a491 100644 --- a/main.go +++ b/main.go @@ -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 {