mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-10 07:46:59 +00:00
pull fixes
This commit is contained in:
@@ -119,25 +119,22 @@ func saveModel(model *Model, fn func(total, completed int64)) error {
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
totalSize, _ := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
|
||||
remaining, _ := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
|
||||
completed := size
|
||||
|
||||
totalBytes := size
|
||||
totalSize += size
|
||||
total := remaining + completed
|
||||
|
||||
for {
|
||||
n, err := io.CopyN(out, resp.Body, 8192)
|
||||
fn(total, completed)
|
||||
if completed >= total {
|
||||
return os.Rename(model.TempFile(), model.FullName())
|
||||
}
|
||||
|
||||
n , err := io.CopyN(out, resp.Body, 8192)
|
||||
if err != nil && !errors.Is(err, io.EOF) {
|
||||
return err
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
totalBytes += n
|
||||
fn(totalSize, totalBytes)
|
||||
completed += n
|
||||
}
|
||||
|
||||
fn(totalSize, totalSize)
|
||||
return os.Rename(model.TempFile(), model.FullName())
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func pull(c *gin.Context) {
|
||||
ch <- api.PullProgress{
|
||||
Total: total,
|
||||
Completed: completed,
|
||||
Percent: float64(total) / float64(completed) * 100,
|
||||
Percent: float64(completed) / float64(total) * 100,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user