prefer the Policy if it is built instead of the DepCache and
[ntk/apt.git] / cmdline / cacheset.cc
index b96b604..78c9d3f 100644 (file)
@@ -416,12 +416,13 @@ VersionSet VersionSet::FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator co
 pkgCache::VerIterator VersionSet::getCandidateVer(pkgCacheFile &Cache,
                pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
        pkgCache::VerIterator Cand;
-       if (Cache.IsDepCacheBuilt() == true)
-               Cand = Cache[Pkg].CandidateVerIter(Cache);
-       else {
+       if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false)
+       {
                if (unlikely(Cache.GetPolicy() == 0))
                        return pkgCache::VerIterator(Cache);
                Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
+       } else {
+               Cand = Cache[Pkg].CandidateVerIter(Cache);
        }
        if (Cand.end() == true)
                return helper.canNotFindCandidateVer(Cache, Pkg);