From: Julian Andres Klode Date: Thu, 27 Aug 2015 11:10:02 +0000 (+0200) Subject: cacheset: Prefer the depcache over the policy again X-Git-Tag: 1.1.exp11~5 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/b6192267c23ffda1b9c8328537a5f2c83e176c26?ds=sidebyside 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. --- diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index af607a197..6a625184e 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -696,12 +696,12 @@ bool VersionContainerInterface::FromDependency(VersionContainerInterface * const pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) { 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); + } else if (unlikely(Cache.GetPolicy() == nullptr)) { + return pkgCache::VerIterator(Cache); + } else { + Cand = Cache.GetPolicy()->GetCandidateVer(Pkg); } if (Cand.end() == true) return helper.canNotGetVersion(CacheSetHelper::CANDIDATE, Cache, Pkg);