clean
This commit is contained in:
parent
ea837412c2
commit
0d5a72aba9
12
cmd/cmd.go
12
cmd/cmd.go
@ -312,22 +312,19 @@ func createBlob(cmd *cobra.Command, client *api.Client, path string) (string, er
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
if client.IsLocal() {
|
if client.IsLocal() {
|
||||||
config, err := getLocalPath(cmd.Context(), digest)
|
dest, err := getLocalPath(cmd.Context(), digest)
|
||||||
|
|
||||||
if errors.Is(err, ErrBlobExists) {
|
if errors.Is(err, ErrBlobExists) {
|
||||||
return digest, nil
|
return digest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
dest := config
|
|
||||||
err = createBlobLocal(path, dest)
|
err = createBlobLocal(path, dest)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return digest, nil
|
return digest, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = client.CreateBlob(cmd.Context(), digest, bin); err != nil {
|
if err = client.CreateBlob(cmd.Context(), digest, bin); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -344,13 +341,12 @@ func getLocalPath(ctx context.Context, digest string) (string, error) {
|
|||||||
Host: net.JoinHostPort(ollamaHost.Host, ollamaHost.Port),
|
Host: net.JoinHostPort(ollamaHost.Host, ollamaHost.Port),
|
||||||
}
|
}
|
||||||
|
|
||||||
var reqBody io.Reader
|
|
||||||
data, err := json.Marshal(digest)
|
data, err := json.Marshal(digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
reqBody = bytes.NewReader(data)
|
reqBody := bytes.NewReader(data)
|
||||||
path := fmt.Sprintf("/api/blobs/%s", digest)
|
path := fmt.Sprintf("/api/blobs/%s", digest)
|
||||||
requestURL := base.JoinPath(path)
|
requestURL := base.JoinPath(path)
|
||||||
request, err := http.NewRequestWithContext(ctx, http.MethodPost, requestURL.String(), reqBody)
|
request, err := http.NewRequestWithContext(ctx, http.MethodPost, requestURL.String(), reqBody)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user