Skip to content

Commit

Permalink
Use the correct lock for reading and writing
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Aug 5, 2024
1 parent b2d1aa0 commit 1a36a2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions v2/pkgs/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ func rename(base string) extract.Renamer {
}

func (t *Tools) readInstalled() error {
t.mutex.Lock()
defer t.mutex.Unlock()
t.mutex.RLock()
defer t.mutex.RUnlock()
// read installed.json
installedFile, err := utilities.SafeJoin(t.folder, "installed.json")
if err != nil {
Expand All @@ -305,8 +305,8 @@ func (t *Tools) readInstalled() error {
}

func (t *Tools) writeInstalled(path string) error {
t.mutex.RLock()
defer t.mutex.RUnlock()
t.mutex.Lock()
defer t.mutex.Unlock()

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

0 comments on commit 1a36a2b

Please sign in to comment.