]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
allow ratelimiting progress reporting for testcases
[apt.git] / apt-pkg / acquire.cc
index 14c8863dcdf7fcf28f8661a34bb6c379ebfb64c8..5e5bec95ce9dbc670a6765b3f526e1378c1e6cb3 100644 (file)
@@ -680,9 +680,12 @@ bool pkgAcquire::Queue::Enqueue(ItemDesc &Item)
 {
    QItem **I = &Items;
    // move to the end of the queue and check for duplicates here
 {
    QItem **I = &Items;
    // move to the end of the queue and check for duplicates here
+   HashStringList const hsl = Item.Owner->GetExpectedHashes();
    for (; *I != 0; I = &(*I)->Next)
    for (; *I != 0; I = &(*I)->Next)
-      if (Item.URI == (*I)->URI
+      if (Item.URI == (*I)->URI || hsl == (*I)->Owner->GetExpectedHashes())
       {
       {
+        if (_config->FindB("Debug::pkgAcquire::Worker",false) == true)
+           std::cerr << " @ Queue: Action combined for " << Item.URI << " and " << (*I)->URI << std::endl;
         (*I)->Owners.push_back(Item.Owner);
         Item.Owner->Status = (*I)->Owner->Status;
         return false;
         (*I)->Owners.push_back(Item.Owner);
         Item.Owner->Status = (*I)->Owner->Status;
         return false;
@@ -952,7 +955,7 @@ std::string pkgAcquire::Queue::QItem::Custom600Headers() const              /*{{{*/
 // AcquireStatus::pkgAcquireStatus - Constructor                       /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // AcquireStatus::pkgAcquireStatus - Constructor                       /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Percent(0), Update(true), MorePulses(false)
+pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Percent(-1), Update(true), MorePulses(false)
 {
    Start();
 }
 {
    Start();
 }
@@ -1051,13 +1054,17 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
       Time = NewTime;
    }
 
       Time = NewTime;
    }
 
+   double const OldPercent = Percent;
    // calculate the percentage, if we have too little data assume 1%
    if (TotalBytes > 0 && UnfetchedReleaseFiles)
       Percent = 0;
    // calculate the percentage, if we have too little data assume 1%
    if (TotalBytes > 0 && UnfetchedReleaseFiles)
       Percent = 0;
-   else 
+   else
       // use both files and bytes because bytes can be unreliable
       // use both files and bytes because bytes can be unreliable
-      Percent = (0.8 * (CurrentBytes/float(TotalBytes)*100.0) + 
+      Percent = (0.8 * (CurrentBytes/float(TotalBytes)*100.0) +
                  0.2 * (CurrentItems/float(TotalItems)*100.0));
                  0.2 * (CurrentItems/float(TotalItems)*100.0));
+   double const DiffPercent = Percent - OldPercent;
+   if (DiffPercent < 0.001 && _config->FindB("Acquire::Progress::Diffpercent", false) == true)
+      return true;
 
    int fd = _config->FindI("APT::Status-Fd",-1);
    if(fd > 0) 
 
    int fd = _config->FindI("APT::Status-Fd",-1);
    if(fd > 0) 
@@ -1075,11 +1082,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
         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);
         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
              << ":"  << std::setprecision(3) << Percent
       // build the status str
       status << "dlstatus:" << i
              << ":"  << std::setprecision(3) << Percent
-             << ":" << msg 
+             << ":" << msg
              << endl;
 
       std::string const dlstatus = status.str();
              << endl;
 
       std::string const dlstatus = status.str();