Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions cmd/pregen.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func pregenHandler(cmd *cobra.Command, args []string) error {
// Open cache
dbPath, err := config.DBPath()
if err != nil {
logFn("[warn] cannot open cache: %v", err)
return pregenFetch(cfg, proj, logFn)
logFn("[warn] cannot open cache, skipping pregen: %v", err)
return nil
}

store, err := cache.Open(dbPath)
if err != nil {
logFn("[warn] cache open error: %v", err)
return pregenFetch(cfg, proj, logFn)
logFn("[warn] cache open error, skipping pregen: %v", err)
return nil
}
defer store.Close()

Expand Down Expand Up @@ -111,25 +111,3 @@ func pregenHandler(cmd *cobra.Command, args []string) error {
logFn("[debug] pregen complete: graph cached for %s", proj.Name)
return nil
}

// pregenFetch runs the API fetch without a cache (fallback when DB is unavailable).
func pregenFetch(cfg *config.Config, proj *project.Info, logFn func(string, ...interface{})) error {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()

zipData, truncated, err := zip.RepoZip(proj.RootDir)
if err != nil {
logFn("[warn] zip error: %v", err)
return nil
}
if truncated {
logFn("[warn] repo zip truncated at 10 MB limit — large repos may produce incomplete graph analysis")
}

apiClient := api.New(cfg.BaseURL, cfg.APIKey, debug, logFn)
_, err = fetchGraphWithCircularDeps(ctx, apiClient, proj.Name, zipData, logFn)
if err != nil {
logFn("[warn] API error: %v", err)
}
return nil
}