Use sysconf(_SC_ARG_MAX) to find the size of Dpkg::MaxArgBytes
[ntk/apt.git] / apt-pkg / acquire-worker.cc
index 9d90b08..047a655 100644 (file)
 // Include Files                                                       /*{{{*/
 #include <config.h>
 
+#include <apt-pkg/acquire.h>
 #include <apt-pkg/acquire-worker.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/hashes.h>
 
+#include <string>
+#include <vector>
 #include <iostream>
 #include <sstream>
-#include <fstream>
 
 #include <sys/stat.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
 #include <errno.h>
@@ -109,7 +112,12 @@ bool pkgAcquire::Worker::Start()
    // Get the method path
    string Method = _config->FindDir("Dir::Bin::Methods") + Access;
    if (FileExists(Method) == false)
-      return _error->Error(_("The method driver %s could not be found."),Method.c_str());
+   {
+      _error->Error(_("The method driver %s could not be found."),Method.c_str());
+      if (Access == "https")
+        _error->Notice(_("Is the package %s installed?"), "apt-transport-https");
+      return false;
+   }
 
    if (Debug == true)
       clog << "Starting method '" << Method << '\'' << endl;
@@ -305,7 +313,15 @@ bool pkgAcquire::Worker::RunMessages()
            
            OwnerQ->ItemDone(Itm);
            unsigned long long const ServerSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10);
-           if (TotalSize != 0 && ServerSize != TotalSize)
+            bool isHit = StringToBool(LookupTag(Message,"IMS-Hit"),false) ||
+                         StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false);
+            // Using the https method the server might return 200, but the
+            // If-Modified-Since condition is not satsified, libcurl will
+            // discard the download. In this case, however, TotalSize will be
+            // set to the actual size of the file, while ServerSize will be set
+            // to 0. Therefore, if the item is marked as a hit and the
+            // downloaded size (ServerSize) is 0, we ignore TotalSize.
+           if (TotalSize != 0 && (!isHit || ServerSize != 0) && ServerSize != TotalSize)
               _error->Warning("Size of file %s is not what the server reported %s %llu",
                               Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
 
@@ -332,8 +348,7 @@ bool pkgAcquire::Worker::RunMessages()
            // Log that we are done
            if (Log != 0)
            {
-              if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true ||
-                  StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
+              if (isHit)
               {
                  /* Hide 'hits' for local only sources - we also manage to
                     hide gets */
@@ -556,7 +571,7 @@ bool pkgAcquire::Worker::InFdReady()
                                                                        /*}}}*/
 // Worker::MethodFailure - Called when the method fails                        /*{{{*/
 // ---------------------------------------------------------------------
-/* This is called when the method is belived to have failed, probably because
+/* This is called when the method is believed to have failed, probably because
    read returned -1. */
 bool pkgAcquire::Worker::MethodFailure()
 {