Skip to content

Commit

Permalink
fix(dbExecutor): move dbExecutor to runtime config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Aug 16, 2020
1 parent ad9bc9e commit 8165174
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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))
}
10 changes: 4 additions & 6 deletions pkg/dep/depPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"sync"

alpm "github.com/Jguer/go-alpm"
"github.com/leonelquinteros/gotext"
rpc "github.com/mikkeloscar/aur"

Expand Down Expand Up @@ -62,16 +61,15 @@ 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),
make(map[string]db.RepoPackage),
make(map[string]*rpc.Pkg),
make(map[string]*rpc.Pkg),
make([]string, 0),
ae,
dbExecutor,
nil,
}

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pkg/settings/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +36,7 @@ type Runtime struct {
VCSPath string
PacmanConf *pacmanconf.Config
AlpmHandle *alpm.Handle
DBExecutor *db.AlpmExecutor
}

func MakeRuntime() (*Runtime, error) {
Expand Down

0 comments on commit 8165174

Please sign in to comment.