]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
tests: try to support spaces in TMPDIR
[apt.git] / apt-pkg / acquire-worker.cc
index 0f1a162a3880239390794433cf2f6ee05c4252e4..45ee6dde3eecdf4fb35ecab2c3352e64ff0f8080 100644 (file)
@@ -33,6 +33,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <errno.h>
+#include <sstream>
 
 #include <apti18n.h>
                                                                        /*}}}*/
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -253,8 +254,8 @@ bool pkgAcquire::Worker::RunMessages()
            ItemDone();
 
            // Change the status so that it can be dequeued
            ItemDone();
 
            // Change the status so that it can be dequeued
-           for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
-              (*O)->Status = pkgAcquire::Item::StatIdle;
+           for (auto const &O: Itm->Owners)
+              O->Status = pkgAcquire::Item::StatIdle;
            // Mark the item as done (taking care of all queues)
            // and then put it in the main queue again
            std::vector<Item*> const ItmOwners = Itm->Owners;
            // Mark the item as done (taking care of all queues)
            // and then put it in the main queue again
            std::vector<Item*> const ItmOwners = Itm->Owners;
@@ -334,9 +335,10 @@ bool pkgAcquire::Worker::RunMessages()
               for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
                  Log->Pulse((*O)->GetOwner());
 
               for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
                  Log->Pulse((*O)->GetOwner());
 
-           std::string const filename = LookupTag(Message, "Filename", Itm->Owner->DestFile.c_str());
            HashStringList ReceivedHashes;
            {
            HashStringList ReceivedHashes;
            {
+              std::string const givenfilename = LookupTag(Message, "Filename");
+              std::string const filename = givenfilename.empty() ? Itm->Owner->DestFile : givenfilename;
               // see if we got hashes to verify
               for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
               {
               // see if we got hashes to verify
               for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
               {
@@ -357,11 +359,11 @@ bool pkgAcquire::Worker::RunMessages()
                     ReceivedHashes = calc.GetHashStringList();
                  }
               }
                     ReceivedHashes = calc.GetHashStringList();
                  }
               }
-           }
 
 
-           // only local files can refer other filenames and counting them as fetched would be unfair
-           if (Log !=  NULL && filename != Itm->Owner->DestFile)
-              Log->Fetched(ReceivedHashes.FileSize(),atoi(LookupTag(Message,"Resume-Point","0").c_str()));
+              // only local files can refer other filenames and counting them as fetched would be unfair
+              if (Log != NULL && Itm->Owner->Complete == false && Itm->Owner->Local == false && givenfilename == filename)
+                 Log->Fetched(ReceivedHashes.FileSize(),atoi(LookupTag(Message,"Resume-Point","0").c_str()));
+           }
 
            std::vector<Item*> const ItmOwners = Itm->Owners;
            OwnerQ->ItemDone(Itm);
 
            std::vector<Item*> const ItmOwners = Itm->Owners;
            OwnerQ->ItemDone(Itm);
@@ -405,7 +407,13 @@ bool pkgAcquire::Worker::RunMessages()
               else if (Owner->HashesRequired() == true)
                  consideredOkay = false;
               else
               else if (Owner->HashesRequired() == true)
                  consideredOkay = false;
               else
+              {
                  consideredOkay = true;
                  consideredOkay = true;
+                 // even if the hashes aren't usable to declare something secure
+                 // we can at least use them to declare it an integrity failure
+                 if (ExpectedHashes.empty() == false && ReceivedHashes != ExpectedHashes && _config->Find("Acquire::ForceHash").empty())
+                    consideredOkay = false;
+              }
 
               if (consideredOkay == true)
                  consideredOkay = Owner->VerifyDone(Message, Config);
 
               if (consideredOkay == true)
                  consideredOkay = Owner->VerifyDone(Message, Config);