mirror of
https://github.com/Jguer/yay.git
synced 2025-10-07 00:14:22 -04:00
prevent leaking goroutines
This commit is contained in:
parent
260594f42a
commit
c8a74cb4a4
@ -172,12 +172,22 @@ func (v *InfoStore) NeedsUpdate(infos OriginInfoByURL) bool {
|
|||||||
// if we find an update we use this to exit early and return true
|
// if we find an update we use this to exit early and return true
|
||||||
hasUpdate := make(chan struct{})
|
hasUpdate := make(chan struct{})
|
||||||
|
|
||||||
|
closed := make(chan struct{})
|
||||||
|
defer close(closed)
|
||||||
|
|
||||||
checkHash := func(url string, info OriginInfo) {
|
checkHash := func(url string, info OriginInfo) {
|
||||||
hash := v.getCommit(url, info.Branch, info.Protocols)
|
hash := v.getCommit(url, info.Branch, info.Protocols)
|
||||||
|
|
||||||
|
var sendTo chan<- struct{}
|
||||||
if hash != "" && hash != info.SHA {
|
if hash != "" && hash != info.SHA {
|
||||||
hasUpdate <- struct{}{}
|
sendTo = hasUpdate
|
||||||
} else {
|
} else {
|
||||||
finished <- struct{}{}
|
sendTo = finished
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case sendTo <- struct{}{}:
|
||||||
|
case <-closed:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user