do not pull when local is available
This commit is contained in:
parent
a88576e59a
commit
ad84138469
1 changed files with 20 additions and 15 deletions
11
cmd/cmd.go
11
cmd/cmd.go
|
@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error {
|
||||||
if err := pull(args[0]); err != nil {
|
if err := pull(args[0]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Up to date.")
|
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -45,8 +43,11 @@ 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
|
||||||
|
_, err := os.Stat(cacheDir() + "/models/" + model + ".bin")
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, os.ErrNotExist):
|
||||||
client := api.NewClient()
|
client := api.NewClient()
|
||||||
|
|
||||||
var bar *progressbar.ProgressBar
|
var bar *progressbar.ProgressBar
|
||||||
return client.Pull(
|
return client.Pull(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
|
@ -59,6 +60,10 @@ func pull(model string) error {
|
||||||
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…
Add table
Reference in a new issue