]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
* apt-pkg/depcache.cc:
[apt.git] / apt-pkg / acquire-worker.cc
index 78c68737c32f4d3aef1a37de6314e6b4cfd4d3e8..75e03232a1de76a28ed2e57de03159542d6a28d0 100644 (file)
@@ -199,6 +199,17 @@ bool pkgAcquire::Worker::RunMessages()
       pkgAcquire::Queue::QItem *Itm = 0;
       if (URI.empty() == false)
         Itm = OwnerQ->FindItem(URI,this);
+
+      // update used mirror
+      string UsedMirror = LookupTag(Message,"UsedMirror", "");
+      if (!UsedMirror.empty() && 
+          Itm && 
+          Itm->Description.find(" ") != string::npos) 
+      {
+         Itm->Description.replace(0, Itm->Description.find(" "), UsedMirror);
+         // FIXME: will we need this as well?
+         //Itm->ShortDesc = UsedMirror;
+      }
       
       // Determine the message number and dispatch
       switch (Number)
@@ -276,10 +287,10 @@ bool pkgAcquire::Worker::RunMessages()
               Log->Pulse(Owner->GetOwner());
            
            OwnerQ->ItemDone(Itm);
-           if (TotalSize != 0 &&
-               (unsigned)atoi(LookupTag(Message,"Size","0").c_str()) != TotalSize)
-              _error->Warning("Bizarre Error - File size is not what the server reported %s %lu",
-                              LookupTag(Message,"Size","0").c_str(),TotalSize);
+           unsigned long const ServerSize = atol(LookupTag(Message,"Size","0").c_str());
+           if (TotalSize != 0 && ServerSize != TotalSize)
+              _error->Warning("Size of file %s is not what the server reported %s %lu",
+                              Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
 
            // see if there is a hash to verify
            string RecivedHash;
@@ -298,8 +309,7 @@ bool pkgAcquire::Worker::RunMessages()
                       << endl << endl;
               }
            }
-           Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
-                       RecivedHash.c_str(), Config);
+           Owner->Done(Message, ServerSize, RecivedHash.c_str(), Config);
            ItemDone();
            
            // Log that we are done
@@ -527,10 +537,6 @@ bool pkgAcquire::Worker::OutFdReady()
    
    if (Res <= 0)
       return MethodFailure();
-
-   // Hmm.. this should never happen.
-   if (Res < 0)
-      return true;
    
    OutQueue.erase(0,Res);
    if (OutQueue.empty() == true)
@@ -558,7 +564,8 @@ bool pkgAcquire::Worker::MethodFailure()
 {
    _error->Error("Method %s has died unexpectedly!",Access.c_str());
    
-   ExecWait(Process,Access.c_str(),true);
+   // do not reap the child here to show meaningfull error to the user
+   ExecWait(Process,Access.c_str(),false);
    Process = -1;
    close(InFd);
    close(OutFd);