mirror of
https://github.com/Jguer/yay.git
synced 2025-10-09 00:07:14 -04:00
Use MultiError in other goroutines
This commit is contained in:
parent
ff5ed12181
commit
b3e647aee4
9
query.go
9
query.go
@ -477,16 +477,13 @@ func aurInfo(names []string, warnings *aurWarnings) ([]*rpc.Pkg, error) {
|
|||||||
seen := make(map[string]int)
|
seen := make(map[string]int)
|
||||||
var mux sync.Mutex
|
var mux sync.Mutex
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var err error
|
var errs MultiError
|
||||||
|
|
||||||
makeRequest := func(n, max int) {
|
makeRequest := func(n, max int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
tempInfo, requestErr := rpc.Info(names[n:max])
|
tempInfo, requestErr := rpc.Info(names[n:max])
|
||||||
if err != nil {
|
errs.Add(requestErr)
|
||||||
return
|
|
||||||
}
|
|
||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
err = requestErr
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mux.Lock()
|
mux.Lock()
|
||||||
@ -505,7 +502,7 @@ func aurInfo(names []string, warnings *aurWarnings) ([]*rpc.Pkg, error) {
|
|||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
if err != nil {
|
if err := errs.Return(); err != nil {
|
||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
upgrade.go
33
upgrade.go
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
@ -109,7 +108,7 @@ func getVersionDiff(oldVersion, newVersion string) (left, right string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// upList returns lists of packages to upgrade from each source.
|
// upList returns lists of packages to upgrade from each source.
|
||||||
func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
func upList(warnings *aurWarnings) (upSlice, upSlice, error) {
|
||||||
local, remote, _, remoteNames, err := filterPackages()
|
local, remote, _, remoteNames, err := filterPackages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@ -117,9 +116,10 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var develUp upSlice
|
var develUp upSlice
|
||||||
|
var repoUp upSlice
|
||||||
|
var aurUp upSlice
|
||||||
|
|
||||||
var repoErr error
|
var errs MultiError
|
||||||
var aurErr error
|
|
||||||
|
|
||||||
aurdata := make(map[string]*rpc.Pkg)
|
aurdata := make(map[string]*rpc.Pkg)
|
||||||
|
|
||||||
@ -127,7 +127,8 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
fmt.Println(bold(cyan("::") + bold(" Searching databases for updates...")))
|
fmt.Println(bold(cyan("::") + bold(" Searching databases for updates...")))
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
repoUp, repoErr = upRepo(local)
|
repoUp, err = upRepo(local)
|
||||||
|
errs.Add(err)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -136,15 +137,17 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates...")))
|
fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates...")))
|
||||||
|
|
||||||
var _aurdata []*rpc.Pkg
|
var _aurdata []*rpc.Pkg
|
||||||
_aurdata, aurErr = aurInfo(remoteNames, warnings)
|
_aurdata, err = aurInfo(remoteNames, warnings)
|
||||||
if aurErr == nil {
|
errs.Add(err)
|
||||||
|
if err == nil {
|
||||||
for _, pkg := range _aurdata {
|
for _, pkg := range _aurdata {
|
||||||
aurdata[pkg.Name] = pkg
|
aurdata[pkg.Name] = pkg
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
aurUp, aurErr = upAUR(remote, aurdata)
|
aurUp, err = upAUR(remote, aurdata)
|
||||||
|
errs.Add(err)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -163,18 +166,6 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
|
|
||||||
printLocalNewerThanAUR(remote, aurdata)
|
printLocalNewerThanAUR(remote, aurdata)
|
||||||
|
|
||||||
errs := make([]string, 0)
|
|
||||||
for _, e := range []error{repoErr, aurErr} {
|
|
||||||
if e != nil {
|
|
||||||
errs = append(errs, e.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(errs) > 0 {
|
|
||||||
err = fmt.Errorf("%s", strings.Join(errs, "\n"))
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if develUp != nil {
|
if develUp != nil {
|
||||||
names := make(stringSet)
|
names := make(stringSet)
|
||||||
for _, up := range develUp {
|
for _, up := range develUp {
|
||||||
@ -189,7 +180,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
|
|||||||
aurUp = develUp
|
aurUp = develUp
|
||||||
}
|
}
|
||||||
|
|
||||||
return aurUp, repoUp, err
|
return aurUp, repoUp, errs.Return()
|
||||||
}
|
}
|
||||||
|
|
||||||
func upDevel(remote []alpm.Package, aurdata map[string]*rpc.Pkg) (toUpgrade upSlice) {
|
func upDevel(remote []alpm.Package, aurdata map[string]*rpc.Pkg) (toUpgrade upSlice) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user