]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-method.cc
Merge remote-tracking branch 'vnwildman/debian/sid' into debian/sid
[apt.git] / apt-pkg / acquire-method.cc
index 294d78f86e3f3de5feebd741f40ab84f8bd9fbb4..746c553f1cc3cbea8d4518b7e8bca556b3eac825 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/hashes.h>
-
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <string>
+#include <vector>
 #include <iostream>
 #include <stdio.h>
-#include <sys/signal.h>
                                                                        /*}}}*/
 
 using namespace std;
@@ -93,12 +103,7 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
    {
       std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n"
                << "Message: " << Err << " " << IP << "\n";
-      // Dequeue
-      FetchItem *Tmp = Queue;
-      Queue = Queue->Next;
-      delete Tmp;
-      if (Tmp == QueueBack)
-        QueueBack = Queue;
+      Dequeue();
    }
    else
       std::cout << "400 URI Failure\nURI: <UNKNOWN>\nMessage: " << Err << "\n";
@@ -166,6 +171,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
       std::cout << "SHA1-Hash: " << Res.SHA1Sum << "\n";
    if (Res.SHA256Sum.empty() == false)
       std::cout << "SHA256-Hash: " << Res.SHA256Sum << "\n";
+   if (Res.SHA512Sum.empty() == false)
+      std::cout << "SHA512-Hash: " << Res.SHA512Sum << "\n";
    if (UsedMirror.empty() == false)
       std::cout << "UsedMirror: " << UsedMirror << "\n";
    if (Res.GPGVOutput.empty() == false)
@@ -199,19 +206,15 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
         std::cout << "Alt-SHA1-Hash: " << Alt->SHA1Sum << "\n";
       if (Alt->SHA256Sum.empty() == false)
         std::cout << "Alt-SHA256-Hash: " << Alt->SHA256Sum << "\n";
-
+      if (Alt->SHA512Sum.empty() == false)
+         std::cout << "Alt-SHA512-Hash: " << Alt->SHA512Sum << "\n";
+     
       if (Alt->IMSHit == true)
         std::cout << "Alt-IMS-Hit: true\n";
    }
 
    std::cout << "\n" << std::flush;
-
-   // Dequeue
-   FetchItem *Tmp = Queue;
-   Queue = Queue->Next;
-   delete Tmp;
-   if (Tmp == QueueBack)
-      QueueBack = Queue;
+   Dequeue();
 }
                                                                        /*}}}*/
 // AcqMethod::MediaFail - Syncronous request for new media             /*{{{*/
@@ -417,26 +420,14 @@ void pkgAcqMethod::Status(const char *Format,...)
                                                                        /*}}}*/
 // AcqMethod::Redirect - Send a redirect message                       /*{{{*/
 // ---------------------------------------------------------------------
-/* This method sends the redirect message and also manipulates the queue
  to keep the pipeline synchronized. */
+/* This method sends the redirect message and dequeues the item as
* the worker will enqueue again later on to the right queue */
 void pkgAcqMethod::Redirect(const string &NewURI)
 {
    std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n"
             << "New-URI: " << NewURI << "\n"
             << "\n" << std::flush;
-
-   // Change the URI for the request.
-   Queue->Uri = NewURI;
-
-   /* To keep the pipeline synchronized, move the current request to
-      the end of the queue, past the end of the current pipeline. */
-   FetchItem *I;
-   for (I = Queue; I->Next != 0; I = I->Next) ;
-   I->Next = Queue;
-   Queue = Queue->Next;
-   I->Next->Next = 0;
-   if (QueueBack == 0)
-      QueueBack = I->Next;
+   Dequeue();
 }
                                                                         /*}}}*/
 // AcqMethod::FetchResult::FetchResult - Constructor                   /*{{{*/
@@ -456,5 +447,14 @@ void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash)
    MD5Sum = Hash.MD5.Result();
    SHA1Sum = Hash.SHA1.Result();
    SHA256Sum = Hash.SHA256.Result();
+   SHA512Sum = Hash.SHA512.Result();
+}
+                                                                       /*}}}*/
+void pkgAcqMethod::Dequeue() {                                         /*{{{*/
+   FetchItem const * const Tmp = Queue;
+   Queue = Queue->Next;
+   if (Tmp == QueueBack)
+      QueueBack = Queue;
+   delete Tmp;
 }
                                                                        /*}}}*/