From d436d51c7870135ddcf5d88fd6f6f6ed6b37b144 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Thu, 6 Jul 2023 15:03:52 -0400 Subject: [PATCH] clean up model pull --- server/models.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/server/models.go b/server/models.go index a64a60d4..b0cccf46 100644 --- a/server/models.go +++ b/server/models.go @@ -35,7 +35,6 @@ func pull(model string, progressCh chan<- api.PullProgress) error { if err != nil { return fmt.Errorf("failed to pull model: %w", err) } - return saveModel(remote, progressCh) } @@ -76,7 +75,7 @@ func saveModel(model *Model, progressCh chan<- api.PullProgress) error { client := &http.Client{} req, err := http.NewRequest("GET", model.URL, nil) if err != nil { - panic(err) + return fmt.Errorf("failed to download model: %w", err) } // check for resume alreadyDownloaded := 0 @@ -126,19 +125,15 @@ func saveModel(model *Model, progressCh chan<- api.PullProgress) error { for { n, err := resp.Body.Read(buf) - if err != nil && err != io.EOF { return err } - if n == 0 { break } - if _, err := out.Write(buf[:n]); err != nil { return err } - totalBytes += n // send progress updates