Sfoglia il codice sorgente

cacheset: Prefer the depcache over the policy again

By preferring the policy over the depcache, we ignore any changes
we made in the depcache, which makes it impossible for code to
change the candidate used here.

This basically reverts commit 2fbfb111312257fa5fc29b0c2ed386fb712f960e:

 prefer the Policy if it is built instead of the DepCache and
 if DepCache is not available as fallback built the Policy

But it also cleans the code up a bit, by removing one level
of nesting.
Julian Andres Klode 11 anni fa
parent
commit
b6192267c2
1 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 5 5
      apt-pkg/cacheset.cc

+ 5 - 5
apt-pkg/cacheset.cc

@@ -696,12 +696,12 @@ bool VersionContainerInterface::FromDependency(VersionContainerInterface * const
 pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
 pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
 		pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
 	pkgCache::VerIterator Cand;
 	pkgCache::VerIterator Cand;
-	if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false) {
-		if (unlikely(Cache.GetPolicy() == 0))
-			return pkgCache::VerIterator(Cache);
-		Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
-	} else {
+	if (Cache.IsDepCacheBuilt() == true) {
 		Cand = Cache[Pkg].CandidateVerIter(Cache);
 		Cand = Cache[Pkg].CandidateVerIter(Cache);
+	} else if (unlikely(Cache.GetPolicy() == nullptr)) {
+		return pkgCache::VerIterator(Cache);
+	} else {
+		Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
 	}
 	}
 	if (Cand.end() == true)
 	if (Cand.end() == true)
 		return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);
 		return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);