]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
Merge branch 'debian/sid' into debian/experimental
[apt.git] / apt-pkg / acquire-worker.cc
index 44c3e4e17362062714afeeebd9acffb03f2b9f70..64df3c80fe13456734c86ea1e5d94f1fd6f141a8 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>
@@ -323,25 +326,30 @@ bool pkgAcquire::Worker::RunMessages()
                               Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
 
            // see if there is a hash to verify
-           string RecivedHash;
-           HashString expectedHash(Owner->HashSum());
-           if(!expectedHash.empty()) 
+           HashStringList RecivedHashes;
+           HashStringList expectedHashes = Owner->HashSums();
+           for (HashStringList::const_iterator hs = expectedHashes.begin(); hs != expectedHashes.end(); ++hs)
            {
-              string hashTag = expectedHash.HashType()+"-Hash";
-              string hashSum = LookupTag(Message, hashTag.c_str());
-              if(!hashSum.empty())
-                 RecivedHash = expectedHash.HashType() + ":" + hashSum;
-              if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
-              {
-                 clog << "201 URI Done: " << Owner->DescURI() << endl
-                      << "RecivedHash: " << RecivedHash << endl
-                      << "ExpectedHash: " << expectedHash.toStr() 
-                      << endl << endl;
-              }
+              std::string const tagname = hs->HashType() + "-Hash";
+              std::string const hashsum = LookupTag(Message, tagname.c_str());
+              if (hashsum.empty() == false)
+                 RecivedHashes.push_back(HashString(hs->HashType(), hashsum));
+           }
+
+           if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
+           {
+              std::clog << "201 URI Done: " << Owner->DescURI() << endl
+                 << "RecivedHash:" << endl;
+              for (HashStringList::const_iterator hs = RecivedHashes.begin(); hs != RecivedHashes.end(); ++hs)
+                 std::clog <<  "\t- " << hs->toStr() << std::endl;
+              std::clog << "ExpectedHash:" << endl;
+              for (HashStringList::const_iterator hs = expectedHashes.begin(); hs != expectedHashes.end(); ++hs)
+                 std::clog <<  "\t- " << hs->toStr() << std::endl;
+              std::clog << endl;
            }
-           Owner->Done(Message, ServerSize, RecivedHash.c_str(), Config);
+           Owner->Done(Message, ServerSize, RecivedHashes, Config);
            ItemDone();
-           
+
            // Log that we are done
            if (Log != 0)
            {
@@ -363,7 +371,8 @@ bool pkgAcquire::Worker::RunMessages()
         {
            if (Itm == 0)
            {
-              _error->Error("Method gave invalid 400 URI Failure message");
+              std::string const msg = LookupTag(Message,"Message");
+              _error->Error("Method gave invalid 400 URI Failure message: %s", msg.c_str());
               break;
            }
 
@@ -522,6 +531,15 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
    Message.reserve(300);
    Message += "URI: " + Item->URI;
    Message += "\nFilename: " + Item->Owner->DestFile;
+   HashStringList const hsl = Item->Owner->HashSums();
+   for (HashStringList::const_iterator hs = hsl.begin(); hs != hsl.end(); ++hs)
+      Message += "\nExpected-" + hs->HashType() + ": " + hs->HashValue();
+   if(Item->Owner->FileSize > 0)
+   {
+      string MaximumSize;
+      strprintf(MaximumSize, "%llu", Item->Owner->FileSize);
+      Message += "\nMaximum-Size: " + MaximumSize;
+   }
    Message += Item->Owner->Custom600Headers();
    Message += "\n\n";
    
@@ -568,7 +586,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()
 {