go : handle EOF correctly in model download (#3671)

This commit is contained in:
Alan 2026-03-16 12:44:18 +01:00 committed by GitHub
parent 975b979834
commit 79218f51d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -282,13 +282,20 @@ func Download(ctx context.Context, p io.Writer, model, out string) (string, erro
default:
// Read body
n, err := resp.Body.Read(data)
if n > 0 {
if m, err := w.Write(data[:n]); err != nil {
return path, err
} else {
count += int64(m)
}
}
if err != nil {
DownloadReport(p, pct, count, resp.ContentLength)
if err == io.EOF {
DownloadReport(p, pct, count, resp.ContentLength)
return path, nil
}
return path, err
} else if m, err := w.Write(data[:n]); err != nil {
return path, err
} else {
count += int64(m)
}
}
}