projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Applied patch from Aurelien Jarno <aurel32@debian.org> to avoid CPU
[apt.git]
/
ftparchive
/
cachedb.h
diff --git
a/ftparchive/cachedb.h
b/ftparchive/cachedb.h
index 1b043e1aa33aad8f319f826f89bc2b10e50e9628..c10f41eccc5300769f51009935382156c117d504 100644
(file)
--- a/
ftparchive/cachedb.h
+++ b/
ftparchive/cachedb.h
@@
-12,9
+12,7
@@
#ifndef CACHEDB_H
#define CACHEDB_H
#ifndef CACHEDB_H
#define CACHEDB_H
-#ifdef __GNUG__
-#pragma interface "cachedb.h"
-#endif
+
#include <db.h>
#include <string>
#include <db.h>
#include <string>
@@
-44,7
+42,7
@@
class CacheDB
memset(&Key,0,sizeof(Key));
memset(&Data,0,sizeof(Data));
Key.data = TmpKey;
memset(&Key,0,sizeof(Key));
memset(&Data,0,sizeof(Data));
Key.data = TmpKey;
- Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",
Type,FileName.c_str()
);
+ Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",
FileName.c_str(), Type
);
}
inline bool Get()
}
inline bool Get()
@@
-64,19
+62,31
@@
class CacheDB
}
return true;
}
}
return true;
}
+ bool OpenFile();
+ bool GetFileStat();
+ bool GetCurStat();
+ bool LoadControl();
+ bool LoadContents(bool GenOnly);
+ bool GetMD5(bool GenOnly);
+ bool GetSHA1(bool GenOnly);
+ bool GetSHA256(bool GenOnly);
// Stat info stored in the DB, Fixed types since it is written to disk.
// 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)};
+ enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
+ FlSize=(1<<3), FlSHA1=(1<<4), FlSHA256=(1<<5)};
struct StatStore
{
struct StatStore
{
- time_t mtime;
uint32_t Flags;
uint32_t Flags;
+ uint32_t mtime;
+ uint32_t FileSize;
+ uint8_t MD5[16];
+ uint8_t SHA1[20];
+ uint8_t SHA256[32];
} CurStat;
struct StatStore OldStat;
// 'set' state
string FileName;
} CurStat;
struct StatStore OldStat;
// 'set' state
string FileName;
- struct stat FileStat;
FileFd *Fd;
debDebFile *DebFile;
FileFd *Fd;
debDebFile *DebFile;
@@
-85,34
+95,42
@@
class CacheDB
// Data collection helpers
debDebFile::MemControlExtract Control;
ContentsExtract Contents;
// Data collection helpers
debDebFile::MemControlExtract Control;
ContentsExtract Contents;
+ string MD5Res;
+ string SHA1Res;
+ string SHA256Res;
// Runtime statistics
struct Stats
{
double Bytes;
double MD5Bytes;
// Runtime statistics
struct Stats
{
double Bytes;
double MD5Bytes;
+ double SHA1Bytes;
+ double SHA256Bytes;
unsigned long Packages;
unsigned long Misses;
unsigned long DeLinkBytes;
unsigned long Packages;
unsigned long Misses;
unsigned long DeLinkBytes;
- inline void Add(const Stats &S) {Bytes += S.Bytes; MD5Bytes += S.MD5Bytes;
+ inline void Add(const Stats &S) {
+ Bytes += S.Bytes; MD5Bytes += S.MD5Bytes; SHA1Bytes += S.SHA1Bytes;
+ SHA256Bytes += S.SHA256Bytes;
Packages += S.Packages; Misses += S.Misses; DeLinkBytes += S.DeLinkBytes;};
Packages += S.Packages; Misses += S.Misses; DeLinkBytes += S.DeLinkBytes;};
- Stats() : Bytes(0), MD5Bytes(0), Packages(0), Misses(0), DeLinkBytes(0) {};
+ Stats() : Bytes(0), MD5Bytes(0),
SHA1Bytes(0), SHA256Bytes(0),
Packages(0), Misses(0), DeLinkBytes(0) {};
} Stats;
bool ReadyDB(string DB);
inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
inline bool Loaded() {return DBLoaded == true;};
} Stats;
bool ReadyDB(string DB);
inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
inline bool Loaded() {return DBLoaded == true;};
+ inline off_t GetFileSize(void) {return CurStat.FileSize;}
+
bool SetFile(string FileName,struct stat St,FileFd *Fd);
bool SetFile(string FileName,struct stat St,FileFd *Fd);
- bool LoadControl();
- bool LoadContents(bool GenOnly);
- bool GetMD5(string &MD5Res,bool GenOnly);
+ bool GetFileInfo(string FileName, bool DoControl, bool DoContents,
+ bool GenContentsOnly, bool DoMD5, bool DoSHA1, bool DoSHA256);
bool Finish();
bool Clean();
bool Finish();
bool Clean();
- CacheDB(string DB) : Dbp(0), DebFile(0) {ReadyDB(DB);};
+ CacheDB(string DB) : Dbp(0),
Fd(NULL),
DebFile(0) {ReadyDB(DB);};
~CacheDB() {ReadyDB(string()); delete DebFile;};
};
~CacheDB() {ReadyDB(string()); delete DebFile;};
};