summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Benson <dominic@dgeb.net>2016-06-20 13:47:46 +0100
committerJulian Andres Klode <jak@debian.org>2016-06-20 17:35:58 +0200
commit91524387211bdec794f280c78d4f44cb8deba35e (patch)
treefadc41a7e4dec84cf1d308f1340eed257fd881da
parent7fb6227f5239e44ed2e7dfc8dd6f6fc801fba146 (diff)
Reinstate caching of file hashes in apt-ftparchive
Check for cached hash entries to determine which (if any) hash types need to be generated for the current file. In 1.0.9, each hash type was handled by a separate method, each of which checked the cache. It looks like when these code paths were unified (in a311fb96b84757ef8628e6a754232614a53b7891) the cache checks were not incorporated into the new method. (cherry picked from commit 51018e947ab1df3ddba5d7a84ed2284d599d8a12) Pull request Debian/apt#16 Closes: #806924
-rw-r--r--ftparchive/cachedb.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index 17df9c1f1..868029abd 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -434,7 +434,24 @@ static void hex2bytes(uint8_t *bytes, const char *hex, int length) {
}
bool CacheDB::GetHashes(bool const GenOnly, unsigned int const DoHashes)
{
- unsigned int FlHashes = DoHashes & (Hashes::MD5SUM | Hashes::SHA1SUM | Hashes::SHA256SUM | Hashes::SHA512SUM);
+ unsigned int notCachedHashes = 0;
+ if ((CurStat.Flags & FlMD5) != FlMD5)
+ {
+ notCachedHashes = notCachedHashes | Hashes::MD5SUM;
+ }
+ if ((CurStat.Flags & FlSHA1) != FlSHA1)
+ {
+ notCachedHashes = notCachedHashes | Hashes::SHA1SUM;
+ }
+ if ((CurStat.Flags & FlSHA256) != FlSHA256)
+ {
+ notCachedHashes = notCachedHashes | Hashes::SHA256SUM;
+ }
+ if ((CurStat.Flags & FlSHA512) != FlSHA512)
+ {
+ notCachedHashes = notCachedHashes | Hashes::SHA512SUM;
+ }
+ unsigned int FlHashes = DoHashes & notCachedHashes;
HashesList.clear();
if (FlHashes != 0)