[PR #4625] server/download.go: Fix downloading with too much EOF error #11546

Closed
opened 2026-04-12 23:32:06 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/ollama/ollama/pull/4625

State: closed
Merged: No


PR #4436 use io.CopyN instead of io.Copy, CopyN will return io.EOF if src stop early, please refer to:
https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/io/io.go;l=370

func CopyN(dst Writer, src Reader, n int64) (written int64, err error) {
	written, err = Copy(dst, LimitReader(src, n))
	if written == n {
		return n, nil
	}
	if written < n && err == nil {
		// src stopped early; must have been EOF.
		err = EOF
	}
	return
}

Too much io.EOF make the download exceed the max tries easily. #4619 fix some of this issue, this is a follow up fix.

**Original Pull Request:** https://github.com/ollama/ollama/pull/4625 **State:** closed **Merged:** No --- PR #4436 use `io.CopyN` instead of `io.Copy`, `CopyN` will return `io.EOF` if src stop early, please refer to: https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/io/io.go;l=370 ``` func CopyN(dst Writer, src Reader, n int64) (written int64, err error) { written, err = Copy(dst, LimitReader(src, n)) if written == n { return n, nil } if written < n && err == nil { // src stopped early; must have been EOF. err = EOF } return } ``` Too much `io.EOF` make the download exceed the max tries easily. #4619 fix some of this issue, this is a follow up fix.
GiteaMirror added the pull-request label 2026-04-12 23:32:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#11546