diff --git a/CHANGELOG.md b/CHANGELOG.md index bdeaddd..cf3c0ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) - Print the expiration time of TOTP code - Export a wallet in json - Import entries from a json file +- Create the wallets directory ## Changed diff --git a/gpm/config.go b/gpm/config.go index d555687..b075f9d 100644 --- a/gpm/config.go +++ b/gpm/config.go @@ -58,20 +58,29 @@ func (c *Config) Init() error { // Load the configuration from a file func (c *Config) Load(path string) error { - _, err := os.Stat(path) + err := c.Init() if err != nil { - err = c.Init() + return err + } + + if path != "" { + _, err = os.Stat(path) + if err != nil { + + } + + data, err := ioutil.ReadFile(path) + if err != nil { + return err + } + + err = json.Unmarshal(data, &c) if err != nil { return err } } - data, err := ioutil.ReadFile(path) - if err != nil { - return err - } - - err = json.Unmarshal(data, &c) + err = os.MkdirAll(c.WalletDir, 0700) if err != nil { return err }