diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-29 15:11:11 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-29 16:37:57 +0100 |
commit | 25c7a09d4a207bac875817559580f62c9ee07cb5 (patch) | |
tree | c6d92367a3be84be0dee48390505eea51792b6c0 /apt-pkg/pkgcachegen.cc | |
parent | f161603953f92cc3e778439d7149e5b852f65277 (diff) |
Add support for calculating hashes over the entire cache
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 6d3b74361..e5fd121f8 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -101,6 +101,8 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) : else Cache.HeaderP->SetArchitectures(idxArchitecture); + // Calculate the hash for the empty map, so ReMap does not fail + Cache.HeaderP->CacheFileSize = Cache.CacheHash(); Cache.ReMap(); } else @@ -131,7 +133,10 @@ pkgCacheGenerator::~pkgCacheGenerator() return; Cache.HeaderP->Dirty = false; - Cache.HeaderP->CacheFileSize = Map.Size(); + Cache.HeaderP->CacheFileSize = Cache.CacheHash(); + + if (_config->FindB("Debug::pkgCacheGen", false)) + std::clog << "Produced cache with hash " << Cache.HeaderP->CacheFileSize << std::endl; Map.Sync(0,sizeof(pkgCache::Header)); } /*}}}*/ @@ -1534,6 +1539,7 @@ static bool writeBackMMapToFile(pkgCacheGenerator * const Gen, DynamicMMap * con // Write out the proper header Gen->GetCache().HeaderP->Dirty = false; + Gen->GetCache().HeaderP->CacheFileSize = Gen->GetCache().CacheHash(); if (SCacheF.Seek(0) == false || SCacheF.Write(Map->Data(),sizeof(*Gen->GetCache().HeaderP)) == false) return _error->Error(_("IO Error saving source cache")); |