Explorar el Código

create `.ollama` directory if it doesnt exist

Jeffrey Morgan hace 1 año
padre
commit
148f0225c0
Se han modificado 1 ficheros con 7 adiciones y 3 borrados
  1. 7 3
      server/auth.go

+ 7 - 3
server/auth.go

@@ -9,7 +9,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -62,9 +61,14 @@ func getAuthToken(redirData AuthRedirect, regOpts *RegistryOptions) (string, err
 		return "", 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 {
 	if err != nil {
 		log.Printf("Failed to load private key: %v", err)
 		log.Printf("Failed to load private key: %v", err)
 		return "", err
 		return "", err