MCPcopy
hub / github.com/Jguer/yay / syncInfo

Function syncInfo

query.go:37–124  ·  view source on GitHub ↗

SyncInfo serves as a pacman -Si for repo packages and AUR packages.

(ctx context.Context, run *runtime.Runtime,
	cmdArgs *parser.Arguments, pkgS []string, dbExecutor db.Executor,
)

Source from the content-addressed store, hash-verified

35
36// SyncInfo serves as a pacman -Si for repo packages and AUR packages.
37func syncInfo(ctx context.Context, run *runtime.Runtime,
38 cmdArgs *parser.Arguments, pkgS []string, dbExecutor db.Executor,
39) error {
40 var (
41 remoteAurPkgs []aur.Pkg
42 err error
43 missing = false
44 )
45
46 pkgS = query.RemoveInvalidTargets(run.Logger, pkgS, run.Cfg.Mode)
47
48 expandedPackages := []string{}
49 for _, pkg := range pkgS {
50 groupPackages := dbExecutor.PackagesFromGroup(pkg)
51 if len(groupPackages) > 0 {
52 for _, p := range groupPackages {
53 expandedPackages = append(expandedPackages, p.Name())
54 }
55 } else {
56 expandedPackages = append(expandedPackages, pkg)
57 }
58 }
59 pkgS = expandedPackages
60
61 aurS, repoS := packageSlices(pkgS, run.Cfg, dbExecutor)
62
63 if len(repoS) == 0 && len(aurS) == 0 {
64 if run.Cfg.Mode != parser.ModeRepo {
65 aurS = dbExecutor.InstalledRemotePackageNames()
66 }
67
68 if run.Cfg.Mode != parser.ModeAUR {
69 repoS = dbExecutor.InstalledSyncPackageNames()
70 }
71 }
72
73 if len(aurS) != 0 {
74 noDB := make([]string, 0, len(aurS))
75
76 for _, pkg := range aurS {
77 _, name := text.SplitDBFromName(pkg)
78 noDB = append(noDB, name)
79 }
80
81 remoteAurPkgs, err = run.AURClient.Get(ctx, &aur.Query{
82 Needles: noDB,
83 By: aur.Name,
84 })
85 if err != nil {
86 run.Logger.Errorln(err)
87 }
88
89 // Check for any missing packages and print errors for any not found
90 found := mapset.NewThreadUnsafeSet[string]()
91 for i := range remoteAurPkgs {
92 found.Add(remoteAurPkgs[i].Name)
93 }
94

Callers 1

handleSyncFunction · 0.85

Calls 15

RemoveInvalidTargetsFunction · 0.92
SplitDBFromNameFunction · 0.92
packageSlicesFunction · 0.85
printInfoFunction · 0.85
ErrorlnMethod · 0.80
ContainsMethod · 0.80
CopyMethod · 0.80
ClearTargetsMethod · 0.80
AddTargetMethod · 0.80
ExistsDoubleMethod · 0.80
PackagesFromGroupMethod · 0.65

Tested by

no test coverage detected