Implement creating necessary directories when creating private key file
This commit is contained in:
parent
d179ffcd76
commit
225c84e8a8
@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
types2 "github.com/Secured-Finance/dione/blockchain/types"
|
types2 "github.com/Secured-Finance/dione/blockchain/types"
|
||||||
@ -311,6 +312,14 @@ func providePrivateKey(cfg *config.Config) crypto.PrivKey {
|
|||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirName := filepath.Dir(cfg.PrivateKeyPath)
|
||||||
|
if _, err := os.Stat(dirName); os.IsNotExist(err) {
|
||||||
|
err := os.MkdirAll(dirName, 0755)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatalf("Cannot create private key file: %s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Create(cfg.PrivateKeyPath)
|
f, err := os.Create(cfg.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Cannot create private key file: %s, ", err)
|
logrus.Fatalf("Cannot create private key file: %s, ", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user