Skip to content

Commit 33c4d94

Browse files
Use the correct lock for reading and writing
1 parent 48930a2 commit 33c4d94

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

v2/pkgs/tools.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ func rename(base string) extract.Renamer {
286286
}
287287

288288
func (t *Tools) readInstalled() error {
289-
t.mutex.Lock()
290-
defer t.mutex.Unlock()
289+
t.mutex.RLock()
290+
defer t.mutex.RUnlock()
291291
// read installed.json
292292
installedFile, err := utilities.SafeJoin(t.folder, "installed.json")
293293
if err != nil {
@@ -301,8 +301,8 @@ func (t *Tools) readInstalled() error {
301301
}
302302

303303
func (t *Tools) writeInstalled(path string) error {
304-
t.mutex.RLock()
305-
defer t.mutex.RUnlock()
304+
t.mutex.Lock()
305+
defer t.mutex.Unlock()
306306

307307
parts := strings.Split(path, string(filepath.Separator))
308308
tool := parts[len(parts)-2]

0 commit comments

Comments
 (0)