diff options
author | Michael Vogt <mvo@ubuntu.com> | 2014-04-16 14:43:08 +0200 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2014-04-16 14:43:08 +0200 |
commit | d0cfa8adbdd74ad7e363019739c77e713dc982e5 (patch) | |
tree | cb27f24f5af0b2d600aa9fbfa4d8048fe12947ae /apt-pkg/acquire.cc | |
parent | 5572f6bdcb947e11f32e2a035438d9d3899ad46d (diff) |
make the TotalFiles more reliable in apt-get update
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r-- | apt-pkg/acquire.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index a187a00ae..2b427ccd3 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -832,6 +832,9 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) if ((*I)->Local == true) continue; + // see if the method tells us to expect more + TotalItems += (*I)->ExpectedAdditionalItems; + TotalBytes += (*I)->FileSize; if ((*I)->Complete == true) CurrentBytes += (*I)->FileSize; @@ -901,12 +904,17 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) snprintf(msg,sizeof(msg), _("Retrieving file %li of %li"), i, TotalItems); - + // calculate the percentage, if we have too little data assume 0% + int Percent; + if (TotalBytes < 1*1024) + Percent = 0; + else + Percent = (CurrentBytes/float(TotalBytes)*100.0); // build the status str status << "dlstatus:" << i - << ":" << (CurrentBytes/float(TotalBytes)*100.0) - << ":" << msg - << endl; + << ":" << Percent + << ":" << msg + << endl; std::string const dlstatus = status.str(); FileFd::Write(fd, dlstatus.c_str(), dlstatus.size()); |