Improve cache load by a shitload

This commit is contained in:
2023-12-29 15:02:17 -05:00
parent 03e992bf6b
commit 415290de20
2 changed files with 67 additions and 27 deletions

View File

@ -146,7 +146,6 @@ func (c *Cache) LoadProjects() {
defer pBar.Stop()
var curProjects int
for {
select {
case p := <-progressInfo.ProgressChan:
@ -157,8 +156,7 @@ func (c *Cache) LoadProjects() {
// This sucks, has to be a better way, and why is the logger incompatible
// with the progressbar?
pterm.Debug.Println(fmt.Sprintf("Update received: %#v", p))
pBar.Add(p.Projects - curProjects)
curProjects = p.Projects
pBar.Add(p.Projects)
case p := <-progressInfo.ProjectsChan:
c.Projects = append(c.Projects, p...)
case e := <-progressInfo.ErrorChan:
@ -167,7 +165,7 @@ func (c *Cache) LoadProjects() {
c.log.Warn("LoadProjects cancelled", c.log.Args("reason", c.gitlab.Ctx.Err()))
return
case <-progressInfo.DoneChan:
pBar.Add(pBar.Total - curProjects)
// pBar.Add(pBar.Total - curProjects)
fmt.Println("")
c.log.Info("Project load complete")
return