Преглед изворни кода

tell download methods the expected hashes

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.
David Kalnischkies пре 12 година
родитељ
комит
d003a557a5
3 измењених фајлова са 13 додато и 0 уклоњено
  1. 9 0
      apt-pkg/acquire-method.cc
  2. 1 0
      apt-pkg/acquire-method.h
  3. 3 0
      apt-pkg/acquire-worker.cc

+ 9 - 0
apt-pkg/acquire-method.cc

@@ -351,6 +351,15 @@ int pkgAcqMethod::Run(bool Single)
 	       Tmp->LastModified = 0;
 	       Tmp->LastModified = 0;
 	    Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
 	    Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
 	    Tmp->FailIgnore = StringToBool(LookupTag(Message,"Fail-Ignore"),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;
 	    Tmp->Next = 0;
 	    
 	    
 	    // Append it to the list
 	    // Append it to the list

+ 1 - 0
apt-pkg/acquire-method.h

@@ -47,6 +47,7 @@ class pkgAcqMethod
       time_t LastModified;
       time_t LastModified;
       bool IndexFile;
       bool IndexFile;
       bool FailIgnore;
       bool FailIgnore;
+      HashStringList ExpectedHashes;
    };
    };
    
    
    struct FetchResult
    struct FetchResult

+ 3 - 0
apt-pkg/acquire-worker.cc

@@ -530,6 +530,9 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
    Message.reserve(300);
    Message.reserve(300);
    Message += "URI: " + Item->URI;
    Message += "URI: " + Item->URI;
    Message += "\nFilename: " + Item->Owner->DestFile;
    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 += Item->Owner->Custom600Headers();
    Message += "\n\n";
    Message += "\n\n";