mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-14 17:57:06 +00:00
server/internal/registry: make pull send errors with Error field (#10326)
Previously, the pull handler would send an error message in the Status field, this prevented the client from using the message as a signal to stop. In the case of the "run" command, it would follow the pull with a "show" which would print a nearly identical "not found" message for unresolved models. Fixes #10307
This commit is contained in:
@@ -244,6 +244,7 @@ func (s *Local) handleDelete(_ http.ResponseWriter, r *http.Request) error {
|
||||
}
|
||||
|
||||
type progressUpdateJSON struct {
|
||||
Error string `json:"error,omitempty,omitzero"`
|
||||
Status string `json:"status,omitempty,omitzero"`
|
||||
Digest blob.Digest `json:"digest,omitempty,omitzero"`
|
||||
Total int64 `json:"total,omitempty,omitzero"`
|
||||
@@ -348,14 +349,15 @@ func (s *Local) handlePull(w http.ResponseWriter, r *http.Request) error {
|
||||
case err := <-done:
|
||||
flushProgress()
|
||||
if err != nil {
|
||||
var status string
|
||||
if errors.Is(err, ollama.ErrModelNotFound) {
|
||||
status = fmt.Sprintf("error: model %q not found", p.model())
|
||||
return &serverError{
|
||||
Status: 404,
|
||||
Code: "not_found",
|
||||
Message: fmt.Sprintf("model %q not found", p.model()),
|
||||
}
|
||||
} else {
|
||||
status = fmt.Sprintf("error: %v", err)
|
||||
return err
|
||||
}
|
||||
enc.Encode(progressUpdateJSON{Status: status})
|
||||
return nil
|
||||
}
|
||||
|
||||
// Emulate old client pull progress (for now):
|
||||
|
||||
Reference in New Issue
Block a user