Skip to content

Commit 1a36a2b

Browse files
Use the correct lock for reading and writing
1 parent b2d1aa0 commit 1a36a2b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: v2/pkgs/tools.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ func rename(base string) extract.Renamer {
290290
}
291291

292292
func (t *Tools) readInstalled() error {
293-
t.mutex.Lock()
294-
defer t.mutex.Unlock()
293+
t.mutex.RLock()
294+
defer t.mutex.RUnlock()
295295
// read installed.json
296296
installedFile, err := utilities.SafeJoin(t.folder, "installed.json")
297297
if err != nil {
@@ -305,8 +305,8 @@ func (t *Tools) readInstalled() error {
305305
}
306306

307307
func (t *Tools) writeInstalled(path string) error {
308-
t.mutex.RLock()
309-
defer t.mutex.RUnlock()
308+
t.mutex.Lock()
309+
defer t.mutex.Unlock()
310310

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

0 commit comments

Comments
 (0)