summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-04-16 15:28:23 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-04-16 15:28:23 +0200
commit1dca8dc55c1fcf4bda07a7e8285de7f225448697 (patch)
tree25366e329ee89765bbe92c0fb45f6c301ef6375d /apt-pkg
parentd0cfa8adbdd74ad7e363019739c77e713dc982e5 (diff)
load the size from the metaindex into the fetcher to have even more accurate progress information
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc15
-rw-r--r--apt-pkg/acquire-item.h4
-rw-r--r--apt-pkg/acquire.cc5
-rw-r--r--apt-pkg/indexrecords.cc2
-rw-r--r--apt-pkg/indexrecords.h2
5 files changed, 20 insertions, 8 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 6f6b3d59f..d5f8b0cc9 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -936,7 +936,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
Init(URI, URIDesc, ShortDesc);
}
pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
- HashString const &ExpectedHash, indexRecords const *MetaIndexParser)
+ HashString const &ExpectedHash, indexRecords *MetaIndexParser)
: Item(Owner), RealURI(Target->URI), ExpectedHash(ExpectedHash)
{
// autoselect the compression method
@@ -963,6 +963,11 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
else
Verify = true;
+ // load the filesize
+ indexRecords::checkSum *Record = MetaIndexParser->Lookup(string(Target->MetaKey));
+ if(Record)
+ FileSize = Record->Size;
+
Init(Target->URI, Target->Description, Target->ShortDesc);
}
/*}}}*/
@@ -1176,9 +1181,13 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
{
}
pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const *Target,
- HashString const &ExpectedHash, indexRecords const *MetaIndexParser)
+ HashString const &ExpectedHash, indexRecords *MetaIndexParser)
: pkgAcqIndex(Owner, Target, ExpectedHash, MetaIndexParser)
{
+ // load the filesize
+ indexRecords::checkSum *Record = MetaIndexParser->Lookup(string(Target->MetaKey));
+ if(Record)
+ FileSize = Record->Size;
}
/*}}}*/
// AcqIndexTrans::Custom600Headers - Insert custom request headers /*{{{*/
@@ -1575,7 +1584,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
++Target)
{
HashString ExpectedIndexHash;
- const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
+ indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
bool compressedAvailable = false;
if (Record == NULL)
{
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index c12d8d63a..bf5cb09c8 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -756,7 +756,7 @@ class pkgAcqIndex : public pkgAcquire::Item
std::string ShortDesc, HashString ExpectedHash,
std::string compressExt="");
pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
- HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
+ HashString const &ExpectedHash, indexRecords *MetaIndexParser);
void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
};
/*}}}*/
@@ -788,7 +788,7 @@ class pkgAcqIndexTrans : public pkgAcqIndex
pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
std::string ShortDesc);
pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
- HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
+ HashString const &ExpectedHash, indexRecords *MetaIndexParser);
};
/*}}}*/
/** \brief Information about an index file. */ /*{{{*/
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 2b427ccd3..9fc40752f 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -905,8 +905,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
// calculate the percentage, if we have too little data assume 0%
+ // FIXME: the 5k is totally arbitrary
+ // FIXME2: instead, use a algorithm where 50% is based on total bytes
+ // and the other 50% on total files
int Percent;
- if (TotalBytes < 1*1024)
+ if (TotalBytes < 5*1024)
Percent = 0;
else
Percent = (CurrentBytes/float(TotalBytes)*100.0);
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index 5353d1098..68ebdce08 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -53,7 +53,7 @@ APT_PURE time_t indexRecords::GetValidUntil() const
return this->ValidUntil;
}
-APT_PURE const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
+APT_PURE indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
{
std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
if (sum == Entries.end())
diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h
index e31f889ad..2260a4ae1 100644
--- a/apt-pkg/indexrecords.h
+++ b/apt-pkg/indexrecords.h
@@ -41,7 +41,7 @@ class indexRecords
indexRecords(const std::string ExpectedDist);
// Lookup function
- virtual const checkSum *Lookup(const std::string MetaKey);
+ virtual checkSum *Lookup(const std::string MetaKey);
/** \brief tests if a checksum for this file is available */
bool Exists(std::string const &MetaKey) const;
std::vector<std::string> MetaKeys();