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
  • Loading branch information
Florent Biville committed Feb 11, 2019
1 parent eaae38c commit 6ad116d
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 @@ -153,6 +153,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 @@ -324,7 +330,7 @@ func (f *BuilderFactory) latestLayer(buildpacks []Buildpack, dest, builderDir st
return tarFile, err
}

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 6ad116d

Please sign in to comment.