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:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user