diff options
Diffstat (limited to 'ftparchive/cachedb.cc')
-rw-r--r-- | ftparchive/cachedb.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc index dfda827b6..b04244347 100644 --- a/ftparchive/cachedb.cc +++ b/ftparchive/cachedb.cc @@ -26,7 +26,7 @@ // CacheDB::ReadyDB - Ready the DB2 /*{{{*/ // --------------------------------------------------------------------- /* This opens the DB2 file for caching package information */ -bool CacheDB::ReadyDB(string DB) +bool CacheDB::ReadyDB(string const &DB) { int err; @@ -69,7 +69,7 @@ bool CacheDB::ReadyDB(string DB) // apt 0.6.44 if (err == EINVAL) { - _error->Error(_("DB format is invalid. If you upgraded from a older version of apt, please remove and re-create the database.")); + _error->Error(_("DB format is invalid. If you upgraded from an older version of apt, please remove and re-create the database.")); } if (err) { @@ -83,7 +83,7 @@ bool CacheDB::ReadyDB(string DB) return true; } /*}}}*/ -// CacheDB::OpenFile - Open the filei /*{{{*/ +// CacheDB::OpenFile - Open the file /*{{{*/ // --------------------------------------------------------------------- /* */ bool CacheDB::OpenFile() @@ -102,9 +102,9 @@ bool CacheDB::OpenFile() // --------------------------------------------------------------------- /* This gets the size from the database if it's there. If we need * to look at the file, also get the mtime from the file. */ -bool CacheDB::GetFileStat() +bool CacheDB::GetFileStat(bool const &doStat) { - if ((CurStat.Flags & FlSize) == FlSize) + if ((CurStat.Flags & FlSize) == FlSize && doStat == false) { /* Already worked out the file size */ } @@ -139,7 +139,7 @@ bool CacheDB::GetCurStat() if (DBLoaded) { - /* First see if thre is anything about it + /* First see if there is anything about it in the database */ /* Get the flags (and mtime) */ @@ -160,9 +160,9 @@ bool CacheDB::GetCurStat() /*}}}*/ // CacheDB::GetFileInfo - Get all the info about the file /*{{{*/ // --------------------------------------------------------------------- -bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents, - bool GenContentsOnly, - bool DoMD5, bool DoSHA1, bool DoSHA256) +bool CacheDB::GetFileInfo(string const &FileName, bool const &DoControl, bool const &DoContents, + bool const &GenContentsOnly, bool const &DoMD5, bool const &DoSHA1, + bool const &DoSHA256, bool const &checkMtime) { this->FileName = FileName; @@ -171,14 +171,18 @@ bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents, return false; } OldStat = CurStat; - - if (GetFileStat() == false) + + if (GetFileStat(checkMtime) == false) { delete Fd; Fd = NULL; return false; } + /* if mtime changed, update CurStat from disk */ + if (checkMtime == true && OldStat.mtime != CurStat.mtime) + CurStat.Flags = FlSize; + Stats.Bytes += CurStat.FileSize; Stats.Packages++; @@ -247,7 +251,7 @@ bool CacheDB::LoadControl() // CacheDB::LoadContents - Load the File Listing /*{{{*/ // --------------------------------------------------------------------- /* */ -bool CacheDB::LoadContents(bool GenOnly) +bool CacheDB::LoadContents(bool const &GenOnly) { // Try to read the control information out of the DB. if ((CurStat.Flags & FlContents) == FlContents) @@ -297,7 +301,7 @@ static string bytes2hex(uint8_t *bytes, size_t length) { return string(space); } -static inline unsigned char xdig2num(char dig) { +static inline unsigned char xdig2num(char const &dig) { if (isdigit(dig)) return dig - '0'; if ('a' <= dig && dig <= 'f') return dig - 'a' + 10; if ('A' <= dig && dig <= 'F') return dig - 'A' + 10; @@ -318,7 +322,7 @@ static void hex2bytes(uint8_t *bytes, const char *hex, int length) { // CacheDB::GetMD5 - Get the MD5 hash /*{{{*/ // --------------------------------------------------------------------- /* */ -bool CacheDB::GetMD5(bool GenOnly) +bool CacheDB::GetMD5(bool const &GenOnly) { // Try to read the control information out of the DB. if ((CurStat.Flags & FlMD5) == FlMD5) @@ -349,7 +353,7 @@ bool CacheDB::GetMD5(bool GenOnly) // CacheDB::GetSHA1 - Get the SHA1 hash /*{{{*/ // --------------------------------------------------------------------- /* */ -bool CacheDB::GetSHA1(bool GenOnly) +bool CacheDB::GetSHA1(bool const &GenOnly) { // Try to read the control information out of the DB. if ((CurStat.Flags & FlSHA1) == FlSHA1) @@ -380,7 +384,7 @@ bool CacheDB::GetSHA1(bool GenOnly) // CacheDB::GetSHA256 - Get the SHA256 hash /*{{{*/ // --------------------------------------------------------------------- /* */ -bool CacheDB::GetSHA256(bool GenOnly) +bool CacheDB::GetSHA256(bool const &GenOnly) { // Try to read the control information out of the DB. if ((CurStat.Flags & FlSHA256) == FlSHA256) |