fix(dbExecutor): move dbExecutor to runtime config

This commit is contained in:
jguer 2020-07-29 09:16:05 +02:00
parent ad9bc9ef8f
commit 8165174462
No known key found for this signature in database
GPG key ID: 6D6CC9BEA8556B35
4 changed files with 11 additions and 7 deletions

View file

@ -150,7 +150,7 @@ func install(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, ignoreProvide
targets := stringset.FromSlice(cmdArgs.Targets) targets := stringset.FromSlice(cmdArgs.Targets)
dp, err := dep.GetPool(requestTargets, 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) ignoreProviders, config.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN)
if err != nil { if err != nil {
return err return err

View file

@ -10,6 +10,7 @@ import (
pacmanconf "github.com/Morganamilo/go-pacmanconf" pacmanconf "github.com/Morganamilo/go-pacmanconf"
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v10/pkg/db"
"github.com/Jguer/yay/v10/pkg/settings" "github.com/Jguer/yay/v10/pkg/settings"
"github.com/Jguer/yay/v10/pkg/text" "github.com/Jguer/yay/v10/pkg/text"
) )
@ -193,6 +194,8 @@ func main() {
exitOnError(initVCS(runtime.VCSPath)) exitOnError(initVCS(runtime.VCSPath))
config.Runtime.AlpmHandle, config.Runtime.PacmanConf, err = initAlpm(cmdArgs, config.PacmanConf) config.Runtime.AlpmHandle, config.Runtime.PacmanConf, err = initAlpm(cmdArgs, config.PacmanConf)
exitOnError(err) exitOnError(err)
config.Runtime.DBExecutor, err = db.NewExecutor(config.Runtime.AlpmHandle)
exitOnError(err)
exitOnError(handleCmd(cmdArgs, config.Runtime.AlpmHandle)) exitOnError(handleCmd(cmdArgs, config.Runtime.AlpmHandle))
os.Exit(cleanup(config.Runtime.AlpmHandle)) os.Exit(cleanup(config.Runtime.AlpmHandle))
} }

View file

@ -9,7 +9,6 @@ import (
"strings" "strings"
"sync" "sync"
alpm "github.com/Jguer/go-alpm"
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
rpc "github.com/mikkeloscar/aur" rpc "github.com/mikkeloscar/aur"
@ -62,8 +61,7 @@ type Pool struct {
Warnings *query.AURWarnings Warnings *query.AURWarnings
} }
func makePool(alpmHandle *alpm.Handle) *Pool { func makePool(dbExecutor *db.AlpmExecutor) *Pool {
ae, _ := db.NewExecutor(alpmHandle)
dp := &Pool{ dp := &Pool{
make([]Target, 0), make([]Target, 0),
make(stringset.StringSet), make(stringset.StringSet),
@ -71,7 +69,7 @@ func makePool(alpmHandle *alpm.Handle) *Pool {
make(map[string]*rpc.Pkg), make(map[string]*rpc.Pkg),
make(map[string]*rpc.Pkg), make(map[string]*rpc.Pkg),
make([]string, 0), make([]string, 0),
ae, dbExecutor,
nil, nil,
} }
@ -349,11 +347,11 @@ func (dp *Pool) ResolveRepoDependency(pkg db.RepoPackage) {
func GetPool(pkgs []string, func GetPool(pkgs []string,
warnings *query.AURWarnings, warnings *query.AURWarnings,
alpmHandle *alpm.Handle, dbExecutor *db.AlpmExecutor,
mode settings.TargetMode, mode settings.TargetMode,
ignoreProviders, noConfirm, provides bool, ignoreProviders, noConfirm, provides bool,
rebuild string, splitN int) (*Pool, error) { rebuild string, splitN int) (*Pool, error) {
dp := makePool(alpmHandle) dp := makePool(dbExecutor)
dp.Warnings = warnings dp.Warnings = warnings
err := dp.ResolveTargets(pkgs, mode, ignoreProviders, noConfirm, provides, rebuild, splitN) err := dp.ResolveTargets(pkgs, mode, ignoreProviders, noConfirm, provides, rebuild, splitN)

View file

@ -8,6 +8,8 @@ import (
"github.com/Morganamilo/go-pacmanconf" "github.com/Morganamilo/go-pacmanconf"
"github.com/leonelquinteros/gotext" "github.com/leonelquinteros/gotext"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/Jguer/yay/v10/pkg/db"
) )
type TargetMode int type TargetMode int
@ -34,6 +36,7 @@ type Runtime struct {
VCSPath string VCSPath string
PacmanConf *pacmanconf.Config PacmanConf *pacmanconf.Config
AlpmHandle *alpm.Handle AlpmHandle *alpm.Handle
DBExecutor *db.AlpmExecutor
} }
func MakeRuntime() (*Runtime, error) { func MakeRuntime() (*Runtime, error) {