Skip to content

Commit

Permalink
chore: delete bad files if download fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Sep 16, 2023
1 parent bc88896 commit e84d54e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/pkg/util/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func downloadFile(file string, download FileDownload, listeners ...io.Writer) er
if download.Sha1 != "" {
writers = append(writers, hash)
}
if _, err := io.Copy(io.MultiWriter(writers...), res.Body); err != nil {
if _, err = io.Copy(io.MultiWriter(writers...), res.Body); err != nil {
_ = os.Remove(file) // Attempt to delete the file
return err
}

Expand Down

0 comments on commit e84d54e

Please sign in to comment.