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

Closed
opened 2026-04-22 22:07:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/4625
Author: @coolljt0725
Created: 5/25/2024
Status: Closed

Base: mainHead: fix_retry


📝 Commits (2)

  • 4371545 server/download.go: Fix downloading retry issues
  • 90c84ad server/download.go: Avoid using magic number

📊 Changes

1 file changed (+6 additions, -3 deletions)

View changed files

📝 server/download.go (+6 -3)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/4625 **Author:** [@coolljt0725](https://github.com/coolljt0725) **Created:** 5/25/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix_retry` --- ### 📝 Commits (2) - [`4371545`](https://github.com/ollama/ollama/commit/437154501b579c1cf6d93b2a033e880faee2ba1e) server/download.go: Fix downloading retry issues - [`90c84ad`](https://github.com/ollama/ollama/commit/90c84adcf4eccc3fcc8b8240c991f2dbe172650a) server/download.go: Avoid using magic number ### 📊 Changes **1 file changed** (+6 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `server/download.go` (+6 -3) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-22 22:07:54 -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#37419