feat: create the wallets directory

This commit is contained in:
Adrien Waksberg 2019-07-22 22:47:20 +02:00
parent 18f944b4d9
commit c91e650d53
2 changed files with 18 additions and 8 deletions

View file

@ -14,6 +14,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
- Print the expiration time of TOTP code - Print the expiration time of TOTP code
- Export a wallet in json - Export a wallet in json
- Import entries from a json file - Import entries from a json file
- Create the wallets directory
## Changed ## Changed

View file

@ -58,12 +58,15 @@ func (c *Config) Init() error {
// Load the configuration from a file // Load the configuration from a file
func (c *Config) Load(path string) error { func (c *Config) Load(path string) error {
_, err := os.Stat(path) err := c.Init()
if err != nil {
err = c.Init()
if err != nil { if err != nil {
return err return err
} }
if path != "" {
_, err = os.Stat(path)
if err != nil {
} }
data, err := ioutil.ReadFile(path) data, err := ioutil.ReadFile(path)
@ -75,6 +78,12 @@ func (c *Config) Load(path string) error {
if err != nil { if err != nil {
return err return err
} }
}
err = os.MkdirAll(c.WalletDir, 0700)
if err != nil {
return err
}
return nil return nil
} }