X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/4fc6b7570c3e97b65c118b58cdf6729fa94c9b03..ff02180ca8abeec0cc1913abf4ad6697d7b25a36:/ftparchive/cachedb.cc?ds=inline diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc index cc3527ea4..868029abd 100644 --- a/ftparchive/cachedb.cc +++ b/ftparchive/cachedb.cc @@ -45,6 +45,7 @@ CacheDB::~CacheDB() { ReadyDB(); delete DebFile; + CloseFile(); } // CacheDB::ReadyDB - Ready the DB2 /*{{{*/ @@ -433,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) @@ -484,10 +502,15 @@ bool CacheDB::GetHashes(bool const GenOnly, unsigned int const DoHashes) if (GenOnly == true) return true; - return HashesList.push_back(HashString("MD5Sum", bytes2hex(CurStat.MD5, sizeof(CurStat.MD5)))) && - HashesList.push_back(HashString("SHA1", bytes2hex(CurStat.SHA1, sizeof(CurStat.SHA1)))) && - HashesList.push_back(HashString("SHA256", bytes2hex(CurStat.SHA256, sizeof(CurStat.SHA256)))) && - HashesList.push_back(HashString("SHA512", bytes2hex(CurStat.SHA512, sizeof(CurStat.SHA512)))); + bool ret = true; +#define PUSH_BACK_HASH(FLAG, TYPE, VALUE) \ + if ((CurStat.Flags & FLAG) == FLAG) \ + ret &= HashesList.push_back(HashString(TYPE, bytes2hex(VALUE, sizeof(VALUE)))); + PUSH_BACK_HASH(FlMD5, "MD5Sum", CurStat.MD5); + PUSH_BACK_HASH(FlSHA1, "SHA1", CurStat.SHA1); + PUSH_BACK_HASH(FlSHA256, "SHA256", CurStat.SHA256); + PUSH_BACK_HASH(FlSHA512, "SHA512", CurStat.SHA512); + return ret; } /*}}}*/ // CacheDB::Finish - Write back the cache structure /*{{{*/