]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
Bug fixes
[apt.git] / apt-pkg / acquire-worker.cc
index 29d5cd9d59cfff960268afbdc23a5f7a2990b355..972ab2455027de38afa06f40dad1f11fcaa3ac02 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-worker.cc,v 1.22 1999/05/23 06:47:43 jgg Exp $
+// $Id: acquire-worker.cc,v 1.27 1999/08/28 01:49:56 jgg Exp $
 /* ######################################################################
 
    Acquire Worker 
@@ -26,7 +26,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
-#include <wait.h>
 #include <stdio.h>
 #include <errno.h>
                                                                        /*}}}*/
@@ -41,7 +40,9 @@ pkgAcquire::Worker::Worker(Queue *Q,MethodConfig *Cnf,
    Config = Cnf;
    Access = Cnf->Access;
    CurrentItem = 0;
-
+   TotalSize = 0;
+   CurrentSize = 0;
+   
    Construct();   
 }
                                                                        /*}}}*/
@@ -54,6 +55,8 @@ pkgAcquire::Worker::Worker(MethodConfig *Cnf)
    Config = Cnf;
    Access = Cnf->Access;
    CurrentItem = 0;
+   TotalSize = 0;
+   CurrentSize = 0;
    
    Construct();   
 }
@@ -84,8 +87,7 @@ pkgAcquire::Worker::~Worker()
    if (Process > 0)
    {
       kill(Process,SIGINT);
-      if (waitpid(Process,0,0) != Process)
-        _error->Warning("I waited but nothing was there!");
+      ExecWait(Process,Access.c_str(),true);
    }   
 }
                                                                        /*}}}*/
@@ -246,8 +248,13 @@ bool pkgAcquire::Worker::RunMessages()
            pkgAcquire::Item *Owner = Itm->Owner;
            pkgAcquire::ItemDesc Desc = *Itm;
            OwnerQ->ItemDone(Itm);
+           if (TotalSize != 0 && 
+               (unsigned)atoi(LookupTag(Message,"Size","0").c_str()) != TotalSize)
+              _error->Warning("Bizzar Error - File size is not what the server reported %s %u",
+                              LookupTag(Message,"Size","0").c_str(),TotalSize);
+
            Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
-                                         LookupTag(Message,"MD5-Hash"));
+                       LookupTag(Message,"MD5-Hash"));
            ItemDone();
            
            // Log that we are done
@@ -263,7 +270,7 @@ bool pkgAcquire::Worker::RunMessages()
               }               
               else
                  Log->Done(Desc);
-           }       
+           }
            break;
         }       
         
@@ -471,8 +478,7 @@ bool pkgAcquire::Worker::MethodFailure()
 {
    _error->Error("Method %s has died unexpectedly!",Access.c_str());
    
-   if (waitpid(Process,0,0) != Process)
-      _error->Warning("I waited but nothing was there!");
+   ExecWait(Process,Access.c_str(),true);
    Process = -1;
    close(InFd);
    close(OutFd);
@@ -498,6 +504,10 @@ void pkgAcquire::Worker::Pulse()
    if (stat(CurrentItem->Owner->DestFile.c_str(),&Buf) != 0)
       return;
    CurrentSize = Buf.st_size;
+   
+   // Hmm? Should not happen...
+   if (CurrentSize > TotalSize && TotalSize != 0)
+      TotalSize = CurrentSize;
 }
                                                                        /*}}}*/
 // Worker::ItemDone - Called when the current item is finished         /*{{{*/