Commit ad841384 authored by Bruce MacDonald's avatar Bruce MacDonald
Browse files

do not pull when local is available

parent a88576e5
...@@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error { ...@@ -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 { ...@@ -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 { ...@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment