summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcachegen.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-12-29 15:59:41 +0100
committerJulian Andres Klode <jak@debian.org>2015-12-29 16:29:05 +0100
commitf161603953f92cc3e778439d7149e5b852f65277 (patch)
tree3762e10147ae26ad56a98483a4bf9a5b98a2dd27 /apt-pkg/pkgcachegen.cc
parent67c90775b650efe89d7d784cf913526cc3b63d07 (diff)
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.
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r--apt-pkg/pkgcachegen.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index e7bdc615b..6d3b74361 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -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;
}
/*}}}*/
@@ -1563,6 +1567,11 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
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;