Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

fix upload

Michael Yangfe5a8724443e
diff --git a/server/images.go b/server/images.go
index 67d7eee7a..dad5e2dfc 100644
--- a/server/images.go
+++ b/server/images.go
@@ -1188,15 +1188,19 @@ func makeRequestWithRetry(ctx context.Context, method string, requestURL *url.UR
regOpts.Token = token
if body != nil {
- if _, err := body.Seek(0, io.SeekStart); err != nil {
- return nil, err
- }
+ body.Seek(0, io.SeekStart)
}
continue
+ case resp.StatusCode == http.StatusNotFound:
+ return nil, os.ErrNotExist
case resp.StatusCode >= http.StatusBadRequest:
- body, _ := io.ReadAll(resp.Body)
- return nil, fmt.Errorf("on upload registry responded with code %d: %s", resp.StatusCode, body)
+ body, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return nil, fmt.Errorf("%d: %s", resp.StatusCode, err)
+ }
+
+ return nil, fmt.Errorf("%d: %s", resp.StatusCode, body)
default:
return resp, nil
}
diff --git a/server/upload.go b/server/upload.go
index 56a762b34..7cd7aadfd 100644
--- a/server/upload.go
+++ b/server/upload.go
@@ -334,15 +334,13 @@ func uploadBlob(ctx context.Context, mp ModelPath, layer *Layer, opts *RegistryO
requestURL := mp.BaseURL()
requestURL = requestURL.JoinPath("v2", mp.GetNamespaceRepository(), "blobs", layer.Digest)
- resp, err := makeRequest(ctx, http.MethodHead, requestURL, nil, nil, opts)
- if err != nil {
+ resp, err := makeRequestWithRetry(ctx, http.MethodHead, requestURL, nil, nil, opts)
+ switch {
+ case errors.Is(err, os.ErrNotExist):
+ case err != nil:
return err
- }
- defer resp.Body.Close()
-
- switch resp.StatusCode {
- case http.StatusNotFound:
- case http.StatusOK:
+ default:
+ defer resp.Body.Close()
fn(api.ProgressResponse{
Status: fmt.Sprintf("uploading %s", layer.Digest),
Digest: layer.Digest,
@@ -351,8 +349,6 @@ func uploadBlob(ctx context.Context, mp ModelPath, layer *Layer, opts *RegistryO
})
return nil
- default:
- return fmt.Errorf("unexpected status code %d", resp.StatusCode)
}
data, ok := blobUploadManager.LoadOrStore(layer.Digest, &blobUpload{Layer: layer})