toolbox: create tmp dir if missing

Create the tmp dir if the image doesn't have one.
This commit is contained in:
Simone Gotti 2019-04-11 16:46:24 +02:00
parent 634a8a543c
commit 4e07550f30
1 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,12 @@ func init() {
} }
func createFile(r io.Reader) (string, error) { func createFile(r io.Reader) (string, error) {
// create a temp dir if the image doesn't have one
tmpDir := os.TempDir()
if err := os.MkdirAll(tmpDir, 0777); err != nil {
return "", fmt.Errorf("failed to create tmp dir %q", tmpDir)
}
file, err := ioutil.TempFile("", "") file, err := ioutil.TempFile("", "")
if err != nil { if err != nil {
return "", err return "", err