fix(slm): skip re-download when already set up

Setup() now returns early if Status() == StatusReady.
CLI also prints the existing path/size instead of starting a download.
This commit is contained in:
2026-05-07 17:10:16 +02:00
parent 035b63ea83
commit 917cbd07f7
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -1113,6 +1113,11 @@ func runSLMCommand(args []string, cfg *gnomacfg.Config, logger *slog.Logger) int
cfg.SLM.ModelURL = slm.DefaultModelURL
mgr = slm.New(slm.Config{DataDir: dataDir, ModelURL: cfg.SLM.ModelURL}, logger)
}
if mgr.Status() == slm.StatusReady {
mf := mgr.Manifest()
fmt.Printf("already set up: %s (%s)\n", mf.FilePath, humanBytes(mf.Size))
return 0
}
fmt.Printf("downloading %s\n", cfg.SLM.ModelURL)
var start = time.Now()
err := mgr.Setup(context.Background(), func(downloaded, total int64) {
+4
View File
@@ -102,6 +102,10 @@ func (m *Manager) Setup(ctx context.Context, progress func(downloaded, total int
return fmt.Errorf("slm: ModelURL is required")
}
if m.Status() == StatusReady {
return nil
}
if err := os.MkdirAll(m.cfg.DataDir, 0700); err != nil {
return fmt.Errorf("slm: create data dir: %w", err)
}