Skip to content

Commit

Permalink
[cli] Fix temp file deletion on windows (#2712)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Aug 16, 2024
2 parents ed1ee18 + 1fd238a commit 555f23a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cli/internal/promt.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ func ValidateDirForWrite(dir string) (bool, error) {
return false, fmt.Errorf("write permission denied: %v", err)
}

// Delete temp file
defer os.Remove(tempFile.Name())
if err != nil {
return false, err
if tempErr := tempFile.Close(); tempErr != nil {
return false, fmt.Errorf("failed to close temp file: %v", tempErr)
}
if tempErr := os.Remove(tempFile.Name()); tempErr != nil {
return false, fmt.Errorf("failed to remove temp file: %v", tempErr)
}

return true, nil
Expand Down

0 comments on commit 555f23a

Please sign in to comment.