]> git.saurik.com Git - apt.git/commitdiff
add ims check verify
authorMichael Vogt <mvo@debian.org>
Sat, 2 Aug 2014 03:37:43 +0000 (05:37 +0200)
committerMichael Vogt <mvo@debian.org>
Sat, 2 Aug 2014 03:37:43 +0000 (05:37 +0200)
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
test/integration/test-apt-update-ims

index bf6866f17db3218646286e17dbb2c8c99752ea40..e98eaa445f85188b81f1f476d3612b170b089d47 100644 (file)
@@ -1094,6 +1094,9 @@ string pkgAcqIndex::Custom600Headers() const
    return msg;
 }
                                                                        /*}}}*/
+// pkgAcqIndex::Failed - getting the indexfile failed                  /*{{{*/
+// ---------------------------------------------------------------------
+/* */
 void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
 {
    size_t const nextExt = CompressionExtension.find(' ');
@@ -1117,6 +1120,35 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)   /*{{{*/
    Owner->AbortTransaction(TransactionID);
 }
                                                                        /*}}}*/
+// pkgAcqIndex::GetFinalFilename - Return the full final file path      /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::string pkgAcqIndex::GetFinalFilename(std::string const &URI,
+                                          std::string const &compExt)
+{
+   std::string FinalFile = _config->FindDir("Dir::State::lists");
+   FinalFile += URItoFileName(URI);
+   if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
+      FinalFile += ".gz";
+   return FinalFile;
+}
+                                                                       /*}}}*/
+// AcqIndex::ReverifyAfterIMS - Reverify index after an ims-hit        /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqIndex::ReverifyAfterIMS(std::string const &FileName)
+{
+   std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
+   if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
+      DestFile += ".gz";
+
+   // copy FinalFile into partial/ so that we check the hash again
+   string FinalFile = GetFinalFilename(RealURI, compExt);
+   Decompression = true;
+   Desc.URI = "copy:" + FinalFile;
+   QueueURI(Desc);
+}
+                                                                       /*}}}*/
 // AcqIndex::Done - Finished a fetch                                   /*{{{*/
 // ---------------------------------------------------------------------
 /* This goes through a number of states.. On the initial fetch the
@@ -1128,6 +1160,8 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
                       pkgAcquire::MethodConfig *Cfg)
 {
    Item::Done(Message,Size,Hashes,Cfg);
+   std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
+
 
    if (Decompression == true)
    {
@@ -1176,9 +1210,7 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
 #endif
 
       // Done, queue for rename on transaction finished
-      string FinalFile = _config->FindDir("Dir::State::lists");
-      FinalFile += URItoFileName(RealURI);
-      DestFile = FinalFile;
+      DestFile = GetFinalFilename(RealURI, compExt);
 
       return;
    } else {
@@ -1206,7 +1238,10 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
    {
       // The files timestamp matches
       if (StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
+      {
+         ReverifyAfterIMS(FileName);
         return;
+      }
       Decompression = true;
       Local = true;
       DestFile += ".decomp";
@@ -1223,13 +1258,10 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
       ErrorText = "Method gave a blank filename";
    }
 
-   std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
-
    // The files timestamp matches
-   if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) {
-       if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
-         // Update DestFile for .gz suffix so that the clean operation keeps it
-         DestFile += ".gz";
+   if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+   {
+      ReverifyAfterIMS(FileName);
       return;
     }
 
index e191e255471925a874fe3cea02aa6cc4f7e726f2..31279f7dfdea5fffbc07cb631843b1d0f5dc7dd9 100644 (file)
@@ -873,6 +873,14 @@ class pkgAcqIndex : public pkgAcqBaseIndex
    /** \brief Auto select the right compression to use */
    void AutoSelectCompression();
 
+   /** \brief Get the full pathname of the final file for the given URI
+    */
+   std::string GetFinalFilename(std::string const &URI,
+                                std::string const &compExt);
+
+   /** \brief Schedule file for verification after a IMS hit */
+   void ReverifyAfterIMS(std::string const &FileName);
+
    public:
    
    // Specialized action members
index cf2b28bb55f82ff787ca0707a736606943231462..3bd6e843c608d9240787b63542375bbca7dd803f 100755 (executable)
@@ -20,3 +20,6 @@ Hit http://localhost:8080 unstable/main amd64 Packages
 Hit http://localhost:8080 unstable/main Translation-en
 Reading package lists..." aptget update 
 
+# ensure that we still do a hash check on ims hit
+msgtest 'Test I-M-S reverify'
+aptget update -o Debug::pkgAcquire::Auth=1 2>&1 | grep -A1 'RecivedHash:' | grep -q -- '- SHA' && msgpass || msgfail