@@ -221,10 +221,6 @@ func (p *PkgResolver) Clone() *PkgResolver {
221221// NewPkgResolver creates a new pkgResolver from a list of indexes.
222222// The indexes are anything that implements NamedIndex.
223223func NewPkgResolver (ctx context.Context , indexes []NamedIndex ) * PkgResolver {
224- return globalResolverCache .Get (ctx , indexes )
225- }
226-
227- func newPkgResolver (ctx context.Context , indexes []NamedIndex ) * PkgResolver {
228224 _ , span := otel .Tracer ("go-apk" ).Start (ctx , "NewPkgResolver" )
229225 defer span .End ()
230226
@@ -485,12 +481,15 @@ func (p *PkgResolver) constrain(constraints []string, dq map[*RepositoryPackage]
485481
486482// GetPackagesWithDependencies get all of the dependencies for the given packages based on the
487483// indexes. Does not filter for installed already or not.
488- func (p * PkgResolver ) GetPackagesWithDependencies (ctx context.Context , packages []string , allArchs map [string ][] NamedIndex ) (toInstall []* RepositoryPackage , conflicts []string , err error ) {
484+ func (p * PkgResolver ) GetPackagesWithDependencies (ctx context.Context , packages []string , dq map [* RepositoryPackage ] string ) (toInstall []* RepositoryPackage , conflicts []string , err error ) {
489485 _ , span := otel .Tracer ("go-apk" ).Start (ctx , "GetPackagesWithDependencies" )
490486 defer span .End ()
491487
492- // Tracks all the packages we have disqualified and the reason we disqualified them.
493- dq := globalDisqualifyCache .Get (ctx , allArchs )
488+ if dq == nil {
489+ // Make sure we have a map to avoid panics. The code below mutates this map, so we need
490+ // it to not be nil in all cases.
491+ dq = map [* RepositoryPackage ]string {}
492+ }
494493
495494 // We're going to mutate this as our set of input packages to install, so make a copy.
496495 constraints := slices .Clone (packages )
@@ -1136,7 +1135,7 @@ func maybedqerror(pkgs []*repositoryPackage, dq map[*RepositoryPackage]string) e
11361135 return errors .New ("not in indexes" )
11371136}
11381137
1139- func disqualifyDifference (ctx context.Context , byArch map [string ][]NamedIndex ) map [* RepositoryPackage ]string {
1138+ func disqualifyDifference (ctx context.Context , byArch map [string ][]NamedIndex , resolverCache * resolverCache ) map [* RepositoryPackage ]string {
11401139 dq := map [* RepositoryPackage ]string {}
11411140
11421141 if len (byArch ) == 1 {
@@ -1164,7 +1163,7 @@ func disqualifyDifference(ctx context.Context, byArch map[string][]NamedIndex) m
11641163 }
11651164
11661165 for arch := range allowablePackages {
1167- p := newPkgResolver (ctx , byArch [arch ])
1166+ p := resolverCache . get (ctx , byArch [arch ])
11681167 for otherArch , allowed := range allowablePackages {
11691168 if otherArch == arch {
11701169 continue
0 commit comments