Skip to content

Commit

Permalink
fix: fetcher - correct use of tmpFile
Browse files Browse the repository at this point in the history
  • Loading branch information
exu committed Feb 1, 2022
1 parent 633848b commit fb20ba9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/executor/content/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -100,13 +99,11 @@ func (f Fetcher) gitURI(repo *testkube.Repository) (uri string, err error) {

func (f Fetcher) saveTempFile(reader io.Reader) (path string, err error) {
tmpFile, err := ioutil.TempFile("", "fetcher-save-temp-file")
path = tmpFile.Name()
out, err := os.Create(path)
if err != nil {
return path, err
return "", err
}
defer out.Close()
_, err = io.Copy(out, reader)
defer tmpFile.Close()
_, err = io.Copy(tmpFile, reader)

return
return tmpFile.Name(), err
}

0 comments on commit fb20ba9

Please sign in to comment.