do not pull when local is available

This commit is contained in:
Bruce MacDonald 2023-07-07 10:22:37 -04:00
parent a88576e59a
commit ad84138469

View file

@ -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 {