]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
* merged with mainline
[apt.git] / apt-pkg / acquire.cc
index 70dce4f540a4ac23e047cd1e855cf4840cb01fca..57cf60bfe1f46bbf2851b46768bc372c394ebc53 100644 (file)
@@ -26,6 +26,7 @@
 #include <apti18n.h>
 
 #include <iostream>
+#include <sstream>
     
 #include <dirent.h>
 #include <sys/time.h>
@@ -265,7 +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;
 }
                                                                        /*}}}*/
@@ -803,6 +808,26 @@ 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);
+
+      snprintf(msg,sizeof(msg), _("Downloading file %li of %li (%s remaining)"), i, TotalItems, TimeToStr(ETA).c_str());
+
+      // 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;
 }
                                                                        /*}}}*/