From a41589f4d4b1a4efa9562384db63b8493cf742cd Mon Sep 17 00:00:00 2001 From: David Florness Date: Sat, 22 May 2021 18:19:51 -0400 Subject: [PATCH] Properly create axalon data dir --- shared/auth.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/shared/auth.go b/shared/auth.go index 2234324..9bf14f7 100644 --- a/shared/auth.go +++ b/shared/auth.go @@ -22,14 +22,19 @@ type AuthInfo struct { Username string `json:"username"` } -var authFname = xdg.DataHome() + "/axon/auth.json" +var axonDir = xdg.DataHome() + "/axon" +var authFname = axonDir + "/auth.json" func GetAuthInfo() (authInfo *AuthInfo, err error) { if _, err = os.Stat(authFname); os.IsNotExist(err) { fmt.Println("no cached auth data found; inquiring for credentials") authInfo, err = inquireForAuthInfo() - if err == nil { - authInfo.save() + if err != nil { + return nil, err + } + err = authInfo.save() + if err != nil { + return nil, err } return authInfo, err } @@ -126,5 +131,9 @@ func (authInfo *AuthInfo) save() error { if err != nil { return err } + err = os.MkdirAll(axonDir, 0700) + if err != nil { + return err + } return ioutil.WriteFile(authFname, jsonBytes, 0600) } -- 2.38.4