From e600217666c6cfcaa70eddd90450086196a00d3d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 5 Nov 2018 14:00:33 +0000 Subject: [PATCH] config: create config directory on save if it is missing --- fs/config/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/config/config.go b/fs/config/config.go index 6a61047d9..21cbec463 100644 --- a/fs/config/config.go +++ b/fs/config/config.go @@ -445,6 +445,10 @@ func changeConfigPassword() { // if configKey has been set, the file will be encrypted. func saveConfig() error { dir, name := filepath.Split(ConfigPath) + err := os.MkdirAll(dir, os.ModePerm) + if err != nil { + return errors.Wrap(err, "failed to create config directory") + } f, err := ioutil.TempFile(dir, name) if err != nil { return errors.Errorf("Failed to create temp file for new config: %v", err)