make config dir if it doens't exist.

This commit is contained in:
Megan Marsh 2019-10-03 15:16:27 -07:00
parent 7f040dfed8
commit de8e8557ae
1 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,16 @@ func ConfigTmpDir() (string, error) {
configdir = fp
}
_, err = os.Stat(configdir)
if os.IsNotExist(err) {
log.Printf("Config dir %s does not exist; creating...", configdir)
if err = os.MkdirAll(configdir, 0755); err != nil {
return "", err
}
} else if err != nil {
return "", err
}
td, err := ioutil.TempDir(configdir, "tmp")
if err != nil {
return "", fmt.Errorf("Error creating temp dir: %s", err)