Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
aur "github.com/Jguer/aur"
alpm "github.com/Jguer/go-alpm/v2"
mapset "github.com/deckarep/golang-set/v2"
"github.com/leonelquinteros/gotext"

"github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/query"
Expand Down Expand Up @@ -37,9 +38,9 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
cmdArgs *parser.Arguments, pkgS []string, dbExecutor db.Executor,
) error {
var (
info []aur.Pkg
err error
missing = false
remoteAurPkgs []aur.Pkg
err error
missing = false
)

pkgS = query.RemoveInvalidTargets(run.Logger, pkgS, run.Cfg.Mode)
Expand Down Expand Up @@ -77,15 +78,26 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
noDB = append(noDB, name)
}

info, err = run.AURClient.Get(ctx, &aur.Query{
remoteAurPkgs, err = run.AURClient.Get(ctx, &aur.Query{
Needles: noDB,
By: aur.Name,
})
if err != nil {
missing = true

run.Logger.Errorln(err)
}

// Check for any missing packages and print errors for any not found
found := mapset.NewThreadUnsafeSet[string]()
for i := range remoteAurPkgs {
found.Add(remoteAurPkgs[i].Name)
}

for _, name := range noDB {
if !found.Contains(name) {
missing = true
run.Logger.Errorln(gotext.Get("No AUR package found for"), " ", name)
}
}
}

if len(repoS) != 0 || (len(aurS) == 0 && len(repoS) == 0) {
Expand All @@ -100,12 +112,8 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
}
}

if len(aurS) != len(info) {
missing = true
}

for i := range info {
printInfo(run.Logger, run.Cfg, &info[i], cmdArgs.ExistsDouble("i"))
for i := range remoteAurPkgs {
printInfo(run.Logger, run.Cfg, &remoteAurPkgs[i], cmdArgs.ExistsDouble("i"))
}

if missing {
Expand Down