Create directory of database if it does not exist (#650)
* fix: create directory of database if it does not exist
* fix code quality issue
Former-commit-id: 88c95717436489ff9014d88374775cc4c3f265b3 [formerly dc56f2c1c3bf46aac9a23e700780743ad15866c8] [formerly 92c2f9a68d575fb6e13453df6690c72f05ca9598 [formerly de205177f2
]]
Former-commit-id: d0888c2f73fa691b900ddc7cbece6dbef985da96 [formerly a7495f66547f1814d31b1ca41148133d23198fd5]
Former-commit-id: a60afcd1fc6aa5cc88559025d7b3176b60117544
This commit is contained in:
parent
e86dfbe8ff
commit
a90bb28cae
18
cmd/utils.go
18
cmd/utils.go
|
@ -62,18 +62,20 @@ type pythonData struct {
|
|||
|
||||
func dbExists(path string) (bool, error) {
|
||||
stat, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return stat.Size() != 0, nil
|
||||
}
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
return false, err
|
||||
d := filepath.Dir(path)
|
||||
_, err = os.Stat(d)
|
||||
if os.IsNotExist(err) {
|
||||
os.MkdirAll(d, 0700)
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
if stat.Size() == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return false, err
|
||||
}
|
||||
|
||||
func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
|
||||
|
|
Loading…
Reference in New Issue