X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/2c38625920fa67d52ade11fd7d28cdb5373dc31c..90ff41f8a6fdd304ac645f8279464462ca36fccd:/apt-pkg/acquire.cc?ds=sidebyside diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 212c8d52b..fff1b2b6a 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -265,11 +266,11 @@ pkgAcquire::MethodConfig *pkgAcquire::GetConfig(string Access) Worker Work(Conf); if (Work.Start() == false) return 0; - + /* if a method uses DownloadLimit, we switch to SingleInstance mode */ if(_config->FindI("Acquire::"+Access+"::DlLimit",0) > 0) Conf->SingleInstance = true; - + return Conf; } /*}}}*/ @@ -807,6 +808,32 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) Time = NewTime; } + int fd = _config->FindI("APT::Status-Fd",-1); + if(fd > 0) + { + ostringstream status; + + char msg[200]; + long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems; + unsigned long ETA = + (unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS); + + // only show the ETA if it makes sense + if (ETA > 0 && ETA < 172800 /* two days */ ) + snprintf(msg,sizeof(msg), _("Retrieving file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str()); + else + snprintf(msg,sizeof(msg), _("Retrieving file %li of %li"), i, TotalItems); + + + + // build the status str + status << "dlstatus:" << i + << ":" << (CurrentBytes/float(TotalBytes)*100.0) + << ":" << msg + << endl; + write(fd, status.str().c_str(), status.str().size()); + } + return true; } /*}}}*/