mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 11:28:59 +00:00
Reuse existing ensureDir function
This commit is contained in:
parent
1dc894087c
commit
e54036be25
@ -366,17 +366,7 @@ func generate(generateDir string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
l.Fatalln("generate:", err)
|
l.Fatalln("generate:", err)
|
||||||
}
|
}
|
||||||
|
ensureDir(dir, 0700)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
certFile, keyFile := filepath.Join(dir, "cert.pem"), filepath.Join(dir, "key.pem")
|
certFile, keyFile := filepath.Join(dir, "cert.pem"), filepath.Join(dir, "key.pem")
|
||||||
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user