Skip to content

Commit

Permalink
Merge pull request #12 from ndibari-etsy/reorder_error_check_on_relea…
Browse files Browse the repository at this point in the history
…se_download

fix: check err before using file object
  • Loading branch information
simpsonw authored Jan 16, 2024
2 parents 8d0464b + eba734e commit 0e5e5b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/releaseapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,20 @@ func (c *Client) downloadBuild(build Build, checkSha256Sum string) (string, erro
log.Printf("dowloading release archive from %s", build.URL)

zipFile, zipLength, err := c.downloadReleaseArchive(build)
defer os.Remove(zipFile.Name())
defer zipFile.Close()

if err != nil {
return "", err
}

defer os.Remove(zipFile.Name())
defer zipFile.Close()

f, err := os.Open(zipFile.Name())

if err != nil {
return "", errors.Wrap(err, "could not open zip archive")
}

defer f.Close()

h := sha256.New()
Expand Down

0 comments on commit 0e5e5b8

Please sign in to comment.