From 816517446267014368f316bd23bc1fffd3539180 Mon Sep 17 00:00:00 2001 From: jguer Date: Wed, 29 Jul 2020 09:16:05 +0200 Subject: [PATCH] fix(dbExecutor): move dbExecutor to runtime config --- install.go | 2 +- main.go | 3 +++ pkg/dep/depPool.go | 10 ++++------ pkg/settings/runtime.go | 3 +++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/install.go b/install.go index 0ccf4326..68c20e43 100644 --- a/install.go +++ b/install.go @@ -150,7 +150,7 @@ func install(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, ignoreProvide targets := stringset.FromSlice(cmdArgs.Targets) dp, err := dep.GetPool(requestTargets, - warnings, alpmHandle, config.Runtime.Mode, + warnings, config.Runtime.DBExecutor, config.Runtime.Mode, ignoreProviders, config.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN) if err != nil { return err diff --git a/main.go b/main.go index 35e0dea0..5cbc6f0c 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( pacmanconf "github.com/Morganamilo/go-pacmanconf" "github.com/leonelquinteros/gotext" + "github.com/Jguer/yay/v10/pkg/db" "github.com/Jguer/yay/v10/pkg/settings" "github.com/Jguer/yay/v10/pkg/text" ) @@ -193,6 +194,8 @@ func main() { exitOnError(initVCS(runtime.VCSPath)) config.Runtime.AlpmHandle, config.Runtime.PacmanConf, err = initAlpm(cmdArgs, config.PacmanConf) exitOnError(err) + config.Runtime.DBExecutor, err = db.NewExecutor(config.Runtime.AlpmHandle) + exitOnError(err) exitOnError(handleCmd(cmdArgs, config.Runtime.AlpmHandle)) os.Exit(cleanup(config.Runtime.AlpmHandle)) } diff --git a/pkg/dep/depPool.go b/pkg/dep/depPool.go index 0e669261..27b737e5 100644 --- a/pkg/dep/depPool.go +++ b/pkg/dep/depPool.go @@ -9,7 +9,6 @@ import ( "strings" "sync" - alpm "github.com/Jguer/go-alpm" "github.com/leonelquinteros/gotext" rpc "github.com/mikkeloscar/aur" @@ -62,8 +61,7 @@ type Pool struct { Warnings *query.AURWarnings } -func makePool(alpmHandle *alpm.Handle) *Pool { - ae, _ := db.NewExecutor(alpmHandle) +func makePool(dbExecutor *db.AlpmExecutor) *Pool { dp := &Pool{ make([]Target, 0), make(stringset.StringSet), @@ -71,7 +69,7 @@ func makePool(alpmHandle *alpm.Handle) *Pool { make(map[string]*rpc.Pkg), make(map[string]*rpc.Pkg), make([]string, 0), - ae, + dbExecutor, nil, } @@ -349,11 +347,11 @@ func (dp *Pool) ResolveRepoDependency(pkg db.RepoPackage) { func GetPool(pkgs []string, warnings *query.AURWarnings, - alpmHandle *alpm.Handle, + dbExecutor *db.AlpmExecutor, mode settings.TargetMode, ignoreProviders, noConfirm, provides bool, rebuild string, splitN int) (*Pool, error) { - dp := makePool(alpmHandle) + dp := makePool(dbExecutor) dp.Warnings = warnings err := dp.ResolveTargets(pkgs, mode, ignoreProviders, noConfirm, provides, rebuild, splitN) diff --git a/pkg/settings/runtime.go b/pkg/settings/runtime.go index 007133b6..0ef154bb 100644 --- a/pkg/settings/runtime.go +++ b/pkg/settings/runtime.go @@ -8,6 +8,8 @@ import ( "github.com/Morganamilo/go-pacmanconf" "github.com/leonelquinteros/gotext" "github.com/pkg/errors" + + "github.com/Jguer/yay/v10/pkg/db" ) type TargetMode int @@ -34,6 +36,7 @@ type Runtime struct { VCSPath string PacmanConf *pacmanconf.Config AlpmHandle *alpm.Handle + DBExecutor *db.AlpmExecutor } func MakeRuntime() (*Runtime, error) {