Skip to content

Commit

Permalink
Merge pull request #153 from bitmaelum/bm-151
Browse files Browse the repository at this point in the history
Creating directories before saving vault
  • Loading branch information
jaytaph authored Jan 11, 2021
2 parents d7fd228 + 0cb9f0f commit 88ecab9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/bitmaelum/bitmaelum-suite/internal/console"
"github.com/spf13/afero"
Expand Down Expand Up @@ -143,6 +144,12 @@ func (v *Vault) Persist() error {
return err
}

// Create directory first if needed
err = fs.MkdirAll(filepath.Dir(v.path), 0700)
if err != nil {
return err
}

// Make backup of the vault for now
if fileExists {
err = fs.Rename(v.path, v.path+".backup")
Expand Down

0 comments on commit 88ecab9

Please sign in to comment.