fix resume download
This commit is contained in:
parent
3d73ad0c56
commit
c316893545
1 changed files with 16 additions and 20 deletions
36
cmd/cmd.go
36
cmd/cmd.go
|
@ -43,27 +43,23 @@ func RunRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func pull(model string) error {
|
func pull(model string) error {
|
||||||
// TODO: check if the local model is up to date with remote
|
client := api.NewClient()
|
||||||
_, err := os.Stat(cacheDir() + "/models/" + model + ".bin")
|
var bar *progressbar.ProgressBar
|
||||||
switch {
|
return client.Pull(
|
||||||
case errors.Is(err, os.ErrNotExist):
|
context.Background(),
|
||||||
client := api.NewClient()
|
&api.PullRequest{Model: model},
|
||||||
var bar *progressbar.ProgressBar
|
func(progress api.PullProgress) error {
|
||||||
return client.Pull(
|
if bar == nil && progress.Percent == 100 {
|
||||||
context.Background(),
|
// already downloaded
|
||||||
&api.PullRequest{Model: model},
|
return nil
|
||||||
func(progress api.PullProgress) error {
|
}
|
||||||
if bar == nil {
|
if bar == nil {
|
||||||
bar = progressbar.DefaultBytes(progress.Total)
|
bar = progressbar.DefaultBytes(progress.Total)
|
||||||
}
|
}
|
||||||
|
|
||||||
return bar.Set64(progress.Completed)
|
return bar.Set64(progress.Completed)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
case err != nil:
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunGenerate(_ *cobra.Command, args []string) error {
|
func RunGenerate(_ *cobra.Command, args []string) error {
|
||||||
|
|
Loading…
Reference in a new issue