#include <apti18n.h>
/*}}}*/
-CacheDB::CacheDB(std::string const &DB)
+CacheDB::CacheDB(std::string const &DB)
: Dbp(0), Fd(NULL), DebFile(0)
{
TmpKey[0]='\0';
ReadyDB(DB);
-};
+}
CacheDB::~CacheDB()
{
ReadyDB();
delete DebFile;
-};
+ CloseFile();
+}
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
// ---------------------------------------------------------------------
if (Dsc.Read(FileName) == false)
return false;
- if (Dsc.Data == 0)
+ if (Dsc.Length == 0)
return _error->Error(_("Failed to read .dsc"));
-
+
// Write back the control information
InitQuerySource();
- if (Put(Dsc.Data, Dsc.Length) == true)
+ if (Put(Dsc.Data.c_str(), Dsc.Length) == true)
CurStat.Flags |= FlSource;
return true;
if (OpenFile() == false)
return false;
- Hashes hashes;
- if (Fd->Seek(0) == false || hashes.AddFD(*Fd, CurStat.FileSize, FlHashes) == false)
+ Hashes hashes(FlHashes);
+ if (Fd->Seek(0) == false || hashes.AddFD(*Fd, CurStat.FileSize) == false)
return false;
HashStringList hl = hashes.GetHashStringList();
hex2bytes(CurStat.MD5, hs->HashValue().data(), sizeof(CurStat.MD5));
CurStat.Flags |= FlMD5;
}
+ else if (strcasecmp(hs->HashType().c_str(), "Checksum-FileSize") == 0)
+ {
+ // we store it in a different field already
+ }
else
return _error->Error("Got unknown unrequested hashtype %s", hs->HashType().c_str());
}
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 /*{{{*/