resumable downloads

This commit is contained in:
Bruce MacDonald
2023-07-06 14:57:11 -04:00
committed by Jeffrey Morgan
parent 7ee75e19ec
commit c9f45abef3
4 changed files with 42 additions and 17 deletions

View File

@@ -40,7 +40,7 @@ func run(model string) error {
mutex := &sync.Mutex{}
var progressData api.PullProgress
callback := func(progress api.PullProgress) {
pullCallback := func(progress api.PullProgress) {
mutex.Lock()
progressData = progress
if bar == nil {
@@ -60,8 +60,11 @@ func run(model string) error {
bar.Set(int(progress.Completed))
mutex.Unlock()
}
_, err = client.Pull(context.Background(), &pr, callback)
return err
if err := client.Pull(context.Background(), &pr, pullCallback); err != nil {
return err
}
fmt.Println("Up to date.")
return nil
}
func serve() error {