Skip to content

Commit

Permalink
Fixes vmware-tanzu#75 - Cleanup stale file handle
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy St. Clair <[email protected]>
  • Loading branch information
timothysc committed Oct 3, 2017
1 parent 9863dd2 commit c52e2c2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
func GatherResults(waitfile string, url string) error {
var inputFileName []byte
var err error
var outfile *os.File

// just loop looking for a file.
done := false
Expand All @@ -60,9 +61,16 @@ func GatherResults(waitfile string, url string) error {
url += "." + filenameParts[1]
}

defer func() {
if outfile != nil {
outfile.Close()
}
}()

// transmit back the results file.
return DoRequest(url, func() (io.Reader, error) {
outfile, err := os.Open(s)
outfile, err = os.Open(s)
return outfile, errors.WithStack(err)
})

}

0 comments on commit c52e2c2

Please sign in to comment.