Skip to content

Commit c91b407

Browse files
committed
use stricter mutex policy to prevent installed.json corruption
1 parent 76ab40f commit c91b407

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ func (t *Tools) GetLocation(command string) (string, error) {
101101

102102
// writeMap() writes installed map to the json file "installed.json"
103103
func (t *Tools) writeMap() error {
104-
t.mutex.RLock()
104+
t.mutex.Lock()
105105
b, err := json.Marshal(t.installed)
106-
t.mutex.RUnlock()
106+
defer t.mutex.Unlock()
107107
if err != nil {
108108
return err
109109
}

0 commit comments

Comments
 (0)