Commit 755e351b authored by Vijay Kumar Chauhan's avatar Vijay Kumar Chauhan
Browse files

Merge branch 'coreimmudb_Dir_issue' into 'coreimmudb'

Immudb new folder / directory creation issue fix

See merge request !262
parents 85bf7ab4 d4eb6703
Branches
Tags
3 merge requests!270Core ImmuDB package and TOTP plugin - Implementation,!269Core ImmuDB package and TOTP plugin - Implementation,!262Immudb new folder / directory creation issue fix
Showing with 6 additions and 5 deletions
......@@ -94,11 +94,10 @@ func InitUsingJson(filePath string) error {
opts.Address = h.Server
opts.Port = h.Port
if h.Dir != "" {
if _, err := os.ReadDir(h.Dir); err != nil { // Checking directory is present and accessible
if err = os.Mkdir(h.Dir, 0644); err != nil {
if _, err := os.Stat(h.Dir); os.IsNotExist(err) { // Checking directory is present and accessible
if err = os.Mkdir(h.Dir, 0642); err != nil {
return err
}
// return err
}
opts.Dir = h.Dir
}
......@@ -135,8 +134,10 @@ func InitImmuDBConnections(hosts []ImmuHost) error {
opts.Address = v.Server
opts.Port = v.Port
if v.Dir != "" {
if _, err := os.ReadDir(v.Dir); err != nil { // Checking directory is present and accessible
return err
if _, err := os.Stat(v.Dir); os.IsNotExist(err) { // Checking directory is present and accessible
if err = os.Mkdir(v.Dir, 0642); err != nil {
return err
}
}
opts.Dir = v.Dir
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment