Przeglądaj źródła

fix mkdir blob path

Michael Yang 1 rok temu
rodzic
commit
f20426a768
2 zmienionych plików z 2 dodań i 16 usunięć
  1. 0 14
      cmd/cmd.go
  2. 2 2
      server/modelpath.go

+ 0 - 14
cmd/cmd.go

@@ -9,7 +9,6 @@ import (
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
-	"path/filepath"
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
@@ -24,15 +23,6 @@ import (
 	"github.com/jmorganca/ollama/server"
 	"github.com/jmorganca/ollama/server"
 )
 )
 
 
-func cacheDir() string {
-	home, err := os.UserHomeDir()
-	if err != nil {
-		panic(err)
-	}
-
-	return filepath.Join(home, ".ollama")
-}
-
 func create(cmd *cobra.Command, args []string) error {
 func create(cmd *cobra.Command, args []string) error {
 	filename, _ := cmd.Flags().GetString("file")
 	filename, _ := cmd.Flags().GetString("file")
 	client := api.NewClient()
 	client := api.NewClient()
@@ -292,10 +282,6 @@ func NewCLI() *cobra.Command {
 		CompletionOptions: cobra.CompletionOptions{
 		CompletionOptions: cobra.CompletionOptions{
 			DisableDefaultCmd: true,
 			DisableDefaultCmd: true,
 		},
 		},
-		PersistentPreRunE: func(_ *cobra.Command, args []string) error {
-			// create the models directory and it's parent
-			return os.MkdirAll(filepath.Join(cacheDir(), "models"), 0o700)
-		},
 	}
 	}
 
 
 	cobra.EnableCommandSorting = false
 	cobra.EnableCommandSorting = false

+ 2 - 2
server/modelpath.go

@@ -106,10 +106,10 @@ func GetBlobsPath(digest string) (string, error) {
 		return "", err
 		return "", err
 	}
 	}
 
 
-	path := filepath.Join(home, ".ollama", "models", "blobs")
+	path := filepath.Join(home, ".ollama", "models", "blobs", digest)
 	if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
 	if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
 		return "", err
 		return "", err
 	}
 	}
 
 
-	return filepath.Join(path, digest), nil
+	return path, nil
 }
 }