From 148f0225c0e6bc0da5e504a4747a45ec68f6987e Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 11 Aug 2023 15:33:11 -0700 Subject: [PATCH] create `.ollama` directory if it doesnt exist --- server/auth.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/auth.go b/server/auth.go index d7803a2b..f5aaa6b1 100644 --- a/server/auth.go +++ b/server/auth.go @@ -9,7 +9,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -62,9 +61,14 @@ func getAuthToken(redirData AuthRedirect, regOpts *RegistryOptions) (string, err return "", err } - keyPath := path.Join(home, ".ollama/id_ed25519") + keyPath := path.Join(home, ".ollama", "id_ed25519") - rawKey, err := ioutil.ReadFile(keyPath) + err = os.MkdirAll(path.Dir(keyPath), 0700) + if err != nil { + return "", fmt.Errorf("could not create .ollama directory %w", err) + } + + rawKey, err := os.ReadFile(keyPath) if err != nil { log.Printf("Failed to load private key: %v", err) return "", err