Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close response body after use when caching downloaded buildpacks #98

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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