-
-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hello!
During the static analysis was found some mistakes:
- The handle 'out' is created at download-with-progressbar.go:31 by calling function 'os.Create' and lost at download-with-progressbar.go:46.
func DownloadFileWithProgressbar(progressbar *pterm.ProgressbarPrinter, outputPath, url string, mode os.FileMode) error {
path := filepath.Clean(outputPath)
out, err := os.Create(path)
if err != nil {
return fmt.Errorf("could not create download path: %w", err)
}
resp, err := http.Get(url) //nolint:gosec
if err != nil {
out.Close()
return fmt.Errorf("error while downloading file: %w", err)
}
defer resp.Body.Close()
counter := &progressbarWriter{}
fileSize, err := strconv.Atoi(resp.Header.Get("Content-Length"))
if err != nil {
return fmt.Errorf("could not determine file size: %w", err)
}
Please clarify whether this requires correction?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working