From d0cfa8adbdd74ad7e363019739c77e713dc982e5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 16 Apr 2014 14:43:08 +0200 Subject: make the TotalFiles more reliable in apt-get update --- apt-pkg/acquire.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'apt-pkg/acquire.cc') 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()); -- cgit v1.2.3