summaryrefslogtreecommitdiff
path: root/ftparchive/cachedb.h
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-06-12 08:44:13 +0200
committerMichael Vogt <mvo@debian.org>2014-06-12 08:44:13 +0200
commit826c5fa7b541e93928791470e5df9342cb7db5ed (patch)
tree80dbc4356344653e80beeb03e51a6b5eb6e50e01 /ftparchive/cachedb.h
parentb2cde5777fd9ab41d1b9fe5ce91196c0d3e8227d (diff)
parentacea28d0a3a55c4df1390c42288043002610fbc9 (diff)
Merge remote-tracking branch 'mvo/feature/apt-ftparchive-srccache2' into ubuntu/trusty
Diffstat (limited to 'ftparchive/cachedb.h')
-rw-r--r--ftparchive/cachedb.h43
1 files changed, 39 insertions, 4 deletions
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h
index 49b9a0ef5..54a274944 100644
--- a/ftparchive/cachedb.h
+++ b/ftparchive/cachedb.h
@@ -22,9 +22,11 @@
#include <stdio.h>
#include "contents.h"
+#include "sources.h"
class FileFd;
+
class CacheDB
{
protected:
@@ -39,7 +41,7 @@ class CacheDB
std::string DBFile;
// Generate a key for the DB of a given type
- inline void InitQuery(const char *Type)
+ void _InitQuery(const char *Type)
{
memset(&Key,0,sizeof(Key));
memset(&Data,0,sizeof(Data));
@@ -47,6 +49,19 @@ class CacheDB
Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",FileName.c_str(), Type);
}
+ void InitQueryStats() {
+ _InitQuery("st");
+ }
+ void InitQuerySource() {
+ _InitQuery("cs");
+ }
+ void InitQueryControl() {
+ _InitQuery("cl");
+ }
+ void InitQueryContent() {
+ _InitQuery("cn");
+ }
+
inline bool Get()
{
return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
@@ -65,10 +80,16 @@ class CacheDB
return true;
}
bool OpenFile();
+ void CloseFile();
+
+ bool OpenDebFile();
+ void CloseDebFile();
+
bool GetFileStat(bool const &doStat = false);
bool GetCurStat();
bool LoadControl();
bool LoadContents(bool const &GenOnly);
+ bool LoadSource();
bool GetMD5(bool const &GenOnly);
bool GetSHA1(bool const &GenOnly);
bool GetSHA256(bool const &GenOnly);
@@ -77,7 +98,8 @@ class CacheDB
// Stat info stored in the DB, Fixed types since it is written to disk.
enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
FlSize=(1<<3), FlSHA1=(1<<4), FlSHA256=(1<<5),
- FlSHA512=(1<<6)};
+ FlSHA512=(1<<6), FlSource=(1<<7),
+ };
struct StatStore
{
@@ -101,6 +123,8 @@ class CacheDB
// Data collection helpers
debDebFile::MemControlExtract Control;
ContentsExtract Contents;
+ DscExtract Dsc;
+
std::string MD5Res;
std::string SHA1Res;
std::string SHA256Res;
@@ -139,8 +163,19 @@ class CacheDB
inline unsigned long long GetFileSize(void) {return CurStat.FileSize;}
bool SetFile(std::string const &FileName,struct stat St,FileFd *Fd);
- bool GetFileInfo(std::string const &FileName, bool const &DoControl, bool const &DoContents, bool const &GenContentsOnly,
- bool const &DoMD5, bool const &DoSHA1, bool const &DoSHA256, bool const &DoSHA512, bool const &checkMtime = false);
+
+ // terrible old overloaded interface
+ bool GetFileInfo(std::string const &FileName,
+ bool const &DoControl,
+ bool const &DoContents,
+ bool const &GenContentsOnly,
+ bool const &DoSource,
+ bool const &DoMD5,
+ bool const &DoSHA1,
+ bool const &DoSHA256,
+ bool const &DoSHA512,
+ bool const &checkMtime = false);
+
bool Finish();
bool Clean();