Browse Source

pkgCacheGenerator: Allow passing down an already created cache

If we already have opened a cache, there is no point in having
to open it again.
tags/debian/1.1.10
Julian Andres Klode 6 years ago
parent
commit
f161603953
3 changed files with 19 additions and 5 deletions
  1. +4
    -2
      apt-pkg/cachefile.cc
  2. +13
    -3
      apt-pkg/pkgcachegen.cc
  3. +2
    -0
      apt-pkg/pkgcachegen.h

+ 4
- 2
apt-pkg/cachefile.cc View File

@@ -96,7 +96,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
BuildSourceList(Progress);

// Read the caches
bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map, true);
Cache = nullptr;
bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map, &Cache, true);
if (Progress != NULL)
Progress->Done();
if (Res == false)
@@ -106,7 +107,8 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
if (_error->PendingError() == true)
_error->Warning(_("You may want to run apt-get update to correct these problems"));

Cache = new pkgCache(Map);
if (Cache == nullptr)
Cache = new pkgCache(Map);
if (_error->PendingError() == true)
return false;
return true;


+ 13
- 3
apt-pkg/pkgcachegen.cc View File

@@ -1285,7 +1285,8 @@ static bool CheckValidity(const string &CacheFile,
pkgSourceList &List,
FileIterator const Start,
FileIterator const End,
MMap **OutMap = 0)
MMap **OutMap = 0,
pkgCache **OutCache = 0)
{
ScopedErrorRevert ser;
bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
@@ -1309,7 +1310,8 @@ static bool CheckValidity(const string &CacheFile,
std::unique_ptr<MMap> Map(new MMap(CacheF,0));
if (unlikely(Map->validData()) == false)
return false;
pkgCache Cache(Map.get());
std::unique_ptr<pkgCache> CacheP(new pkgCache(Map.get()));
pkgCache &Cache = *CacheP.get();
if (_error->PendingError() || Map->Size() == 0)
{
if (Debug == true)
@@ -1399,6 +1401,8 @@ static bool CheckValidity(const string &CacheFile,

if (OutMap != 0)
*OutMap = Map.release();
if (OutCache != 0)
*OutCache = CacheP.release();
return true;
}
/*}}}*/
@@ -1562,6 +1566,11 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
{ return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
MMap **OutMap,bool)
{
return pkgCacheGenerator::MakeStatusCache(List, Progress, OutMap, nullptr, true);
}
bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
MMap **OutMap,pkgCache **OutCache, bool)
{
// FIXME: deprecate the ignored AllowMem parameter
bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
@@ -1594,7 +1603,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
bool srcpkgcache_fine = false;
bool volatile_fine = List.GetVolatileFiles().empty();

if (CheckValidity(CacheFile, List, Files.begin(), Files.end(), volatile_fine ? OutMap : NULL) == true)
if (CheckValidity(CacheFile, List, Files.begin(), Files.end(), volatile_fine ? OutMap : NULL,
volatile_fine ? OutCache : NULL) == true)
{
if (Debug == true)
std::clog << "pkgcache.bin is valid - no need to build any cache" << std::endl;


+ 2
- 0
apt-pkg/pkgcachegen.h View File

@@ -113,6 +113,8 @@ class APT_HIDDEN pkgCacheGenerator /*{{{*/

APT_PUBLIC static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
MMap **OutMap = 0,bool AllowMem = false);
APT_HIDDEN static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
MMap **OutMap,pkgCache **OutCache, bool AllowMem = false);
APT_PUBLIC static bool MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap);

void ReMap(void const * const oldMap, void const * const newMap);


Loading…
Cancel
Save