Reuse existing ensureDir function

This commit is contained in:
Anderson Mesquita 2015-12-18 12:47:26 -05:00
parent 1dc894087c
commit e54036be25

View File

@ -366,17 +366,7 @@ func generate(generateDir string) {
if err != nil {
l.Fatalln("generate:", err)
}
info, err := os.Stat(dir)
if err == nil && !info.IsDir() {
l.Fatalln(dir, "is not a directory")
}
if err != nil && os.IsNotExist(err) {
err = osutil.MkdirAll(dir, 0700)
if err != nil {
l.Fatalln("generate:", err)
}
}
ensureDir(dir, 0700)
certFile, keyFile := filepath.Join(dir, "cert.pem"), filepath.Join(dir, "key.pem")
cert, err := tls.LoadX509KeyPair(certFile, keyFile)