Skip to content

Commit

Permalink
Close response body after use when caching downloaded buildpacks
Browse files Browse the repository at this point in the history
Hopefully fixes #97

Signed-off-by: Florent Biville <[email protected]>
  • Loading branch information
Florent Biville authored and Danny Joyce committed Feb 27, 2019
1 parent 421de22 commit 0c4de9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion builder_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func (f *BuilderFactory) resolveBuildpackURI(builderDir string, b Buildpack) (Bu
dir = cachedDir
break
} else {
defer func() {
err := reader.Close()
if err != nil {
fmt.Printf("warning: could not close %v: %s", reader, err)
}
}()
if err = f.untarZ(reader, cachedDir); err != nil {
return Buildpack{}, err
}
Expand Down Expand Up @@ -327,7 +333,7 @@ func (f *BuilderFactory) latestLayer(buildpacks []Buildpack, dest, builderDir st
return tarFile, nil
}

func (f *BuilderFactory) downloadAsStream(uri string, etag string) (io.Reader, string, error) {
func (f *BuilderFactory) downloadAsStream(uri string, etag string) (io.ReadCloser, string, error) {
c := http.Client{}
req, err := http.NewRequest("GET", uri, nil)
if err != nil {
Expand Down

0 comments on commit 0c4de9f

Please sign in to comment.