mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 12:21:03 +00:00
Fixing infinite loop :o
This commit is contained in:
parent
e22d41de57
commit
e2b76ac449
1 changed files with 7 additions and 20 deletions
|
@ -23,7 +23,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/laszlocph/drone-oss-08/model"
|
"github.com/laszlocph/drone-oss-08/model"
|
||||||
"github.com/laszlocph/drone-oss-08/remote"
|
"github.com/laszlocph/drone-oss-08/remote"
|
||||||
|
@ -253,9 +252,6 @@ func (c *client) Dir(u *model.User, r *model.Repo, b *model.Build, f string) ([]
|
||||||
fc := make(chan *remote.FileMeta)
|
fc := make(chan *remote.FileMeta)
|
||||||
errc := make(chan error)
|
errc := make(chan error)
|
||||||
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(len(data))
|
|
||||||
|
|
||||||
for _, file := range data {
|
for _, file := range data {
|
||||||
go func(path string) {
|
go func(path string) {
|
||||||
content, err := c.File(u, r, b, path)
|
content, err := c.File(u, r, b, path)
|
||||||
|
@ -273,24 +269,15 @@ func (c *client) Dir(u *model.User, r *model.Repo, b *model.Build, f string) ([]
|
||||||
var files []*remote.FileMeta
|
var files []*remote.FileMeta
|
||||||
var errors []error
|
var errors []error
|
||||||
|
|
||||||
go func() {
|
for i := 0; i < len(data); i++ {
|
||||||
for {
|
|
||||||
select {
|
select {
|
||||||
case err, open := <-errc:
|
case err, _ := <-errc:
|
||||||
if open {
|
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
wg.Done()
|
case fileMeta, _ := <-fc:
|
||||||
}
|
|
||||||
case fileMeta, open := <-fc:
|
|
||||||
if open {
|
|
||||||
files = append(files, fileMeta)
|
files = append(files, fileMeta)
|
||||||
wg.Done()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
close(fc)
|
close(fc)
|
||||||
close(errc)
|
close(errc)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue