summaryrefslogtreecommitdiff
path: root/ftparchive/cachedb.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
commitb026dbb970c71213e12caaeb47bf7a27b91ea0a0 (patch)
tree68c68ff6bc12037ac74899f686fce9c0a3e419bd /ftparchive/cachedb.cc
parent07f2526e45f9978201817237745727db6177c29a (diff)
parentd328fd1a20543192a7ea3eac124f10a5793743e9 (diff)
* [BREAK] add possibility to download and use multiply
Translation files, configurable with Acquire::Translation (Closes: #444222, #448216, #550564) * Ignore :qualifiers after package name in build dependencies for now as long we don't understand them (Closes: #558103) * apt-pkg/contrib/mmap.{cc,h}: - extend it to have a growable flag - unused now but maybe... * apt-pkg/pkgcache.h: - use long instead of short for {Ver,Desc}File size, patch from Víctor Manuel Jáquez Leal, thanks! (Closes: #538917) * apt-pkg/acquire-item.cc: - allow also to skip the last patch if target is reached, thanks Bernhard R. Link! (Closes: #545699) * ftparchive/writer.{cc,h}: - add APT::FTPArchive::AlwaysStat to disable the too aggressive caching if versions are build multiply times (not recommend) Patch by Christoph Goehre, thanks! (Closes: #463260)
Diffstat (limited to 'ftparchive/cachedb.cc')
-rw-r--r--ftparchive/cachedb.cc30
1 files changed, 17 insertions, 13 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index e02f0e1b6..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;
@@ -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 */
}
@@ -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)