]> git.saurik.com Git - apt.git/commitdiff
tell download methods the expected hashes
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 27 Apr 2014 21:02:00 +0000 (23:02 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Fri, 9 May 2014 11:06:27 +0000 (13:06 +0200)
Now that we have all hashes in the acquire system, pass the info down to
the methods, so that it can use it in the request and/or to precheck the
response.

apt-pkg/acquire-method.cc
apt-pkg/acquire-method.h
apt-pkg/acquire-worker.cc

index 58d214068ec3d1d86cfb21c2e470a2d4715ad158..e4a937d1dd6de8b363998a43b24abaf48e3a2a0a 100644 (file)
@@ -351,6 +351,15 @@ int pkgAcqMethod::Run(bool Single)
               Tmp->LastModified = 0;
            Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
            Tmp->FailIgnore = StringToBool(LookupTag(Message,"Fail-Ignore"),false);
+           Tmp->ExpectedHashes = HashStringList();
+           for (char const * const * t = HashString::SupportedHashes(); *t != NULL; ++t)
+           {
+              std::string tag = "Expected-";
+              tag.append(*t);
+              std::string const hash = LookupTag(Message, tag.c_str());
+              if (hash.empty() == false)
+                 Tmp->ExpectedHashes.push_back(HashString(*t, hash));
+           }
            Tmp->Next = 0;
            
            // Append it to the list
index 8a17a5fd52fb832974ebec17210e5f28362f6229..cbf79f8609be84b6d72e204e983095696f1ce258 100644 (file)
@@ -47,6 +47,7 @@ class pkgAcqMethod
       time_t LastModified;
       bool IndexFile;
       bool FailIgnore;
+      HashStringList ExpectedHashes;
    };
    
    struct FetchResult
index ec1b2fc469be86573cf42768b6a2a8c79c042a67..54be8e99fbda4d63f95b5e620477287cadcf92f2 100644 (file)
@@ -530,6 +530,9 @@ 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();
    Message += Item->Owner->Custom600Headers();
    Message += "\n\n";