Skip to content

Commit

Permalink
Merge pull request #92 from timothysc/cleanup
Browse files Browse the repository at this point in the history
Fixes #75 - Cleanup stale file handle
  • Loading branch information
timothysc authored Oct 3, 2017
2 parents 9863dd2 + c52e2c2 commit d8711aa
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 d8711aa

Please sign in to comment.