Skip to content

Commit

Permalink
Merge pull request #18 from gkze/fix-save-concurrency-bug
Browse files Browse the repository at this point in the history
Fix save default concurrency bug
  • Loading branch information
gkze authored Apr 13, 2020
2 parents bcbbe29 + 1e255b5 commit b43b307
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions starmanager/starmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func (s *StarManager) starReposFromURLsChan(

wg.Add(1)
go func() { defer wg.Done(); successfulStars <- 1 }()
wg.Wait()
} else {
log.Infof(
"%s/%s does not qualify - archived: %t, pushed: %s\n",
Expand Down Expand Up @@ -493,7 +494,9 @@ func (s *StarManager) SaveStarredPage(
wg.Add(1)
go s.SaveStarredRepository(r, &wg)
}

wg.Wait()
close(errors)

return errors
}
Expand All @@ -512,16 +515,16 @@ func (s *StarManager) SaveAllStars(maxConcurrency int) error {
// We start from 2 by default because we already fetched the first page
// above, we want to avoid repeating that operation
startPage := 2
startIdx := 0
startIdx := startPage
numGoroutines := firstPageResponse.LastPage

// If concurrency is explictly bounded, we alter the parameters to
// accomodate the requirements. By default we start at startPage, otherwise
// we start at 0 since we would like to spin up exactly numGoroutunes
// goroutines.
if maxConcurrency > 0 {
numGoroutines = maxConcurrency + startIdx
startIdx = startPage
numGoroutines = maxConcurrency
startIdx = 0
}

log.Info("Attempting to save the rest of the pages...")
Expand Down

0 comments on commit b43b307

Please sign in to comment.