Skip to content

Commit

Permalink
check return of file mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Feb 6, 2025
1 parent 18deecc commit 1a6bfdd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/mise/mise.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/alexflint/go-filemutex"
"github.com/charmbracelet/log"
)

const (
Expand Down Expand Up @@ -61,8 +62,14 @@ func (m *Mise) runCmd(args ...string) (string, error) {
return "", fmt.Errorf("failed to create mutex: %w", err)
}

mu.Lock() // Will block until lock can be acquired
defer mu.Unlock()
if err := mu.Lock(); err != nil {
return "", fmt.Errorf("failed to acquire lock: %w", err)
}
defer func() {
if err := mu.Unlock(); err != nil {
log.Printf("failed to release lock: %v", err)
}
}()

cmd := exec.Command(m.binaryPath, args...)
var stdout, stderr bytes.Buffer
Expand Down

0 comments on commit 1a6bfdd

Please sign in to comment.