mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
Create directory of database if it does not exist (#650)
* fix: create directory of database if it does not exist * fix code quality issue
This commit is contained in:
parent
17b514510b
commit
de205177f2
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
Block a user