]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
- French updated
[apt.git] / apt-pkg / acquire-item.cc
index a7132ce1d20af0b4f464495096f809ddef064462..9c51184e6d261a414c24f8fa42547aff0cb98f6e 100644 (file)
@@ -345,7 +345,7 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash,
  */
 pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
                                   string URI,string URIDesc,string ShortDesc,
-                                  HashString ExpectedMD5
+                                  HashString ExpectedHash
                                   vector<DiffInfo> diffs)
    : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash), 
      available_patches(diffs)
@@ -641,7 +641,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
          std::cerr << "  Expected Hash: " << ExpectedHash.toStr() << std::endl;
       }
 
-      if (!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile))
+      if (!ExpectedHash.empty() && ExpectedHash.toStr() != Hash)
       {
          Status = StatAuthError;
          ErrorText = _("Hash Sum mismatch");
@@ -675,7 +675,6 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
       // The files timestamp matches
       if (StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
         return;
-
       Decompression = true;
       Local = true;
       DestFile += ".decomp";
@@ -694,7 +693,10 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
    
    // The files timestamp matches
    if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+   {
+      unlink(FileName.c_str());
       return;
+   }
 
    if (FileName == DestFile)
       Erase = true;
@@ -702,7 +704,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
       Local = true;
    
    string compExt = Desc.URI.substr(Desc.URI.size()-3);
-   char *decompProg;
+   const char *decompProg;
    if(compExt == "bz2") 
       decompProg = "bzip2";
    else if(compExt == ".gz") 
@@ -966,18 +968,18 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)
 
    // see if the download was a IMSHit
    IMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false);
-
    Complete = true;
 
    string FinalFile = _config->FindDir("Dir::State::lists");
    FinalFile += URItoFileName(RealURI);
 
-   // The files timestamp matches
-   if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == false)
-   {
-      // Move it into position
+   // If we get a IMS hit we can remove the empty file in partial
+   // othersie we move the file in place
+   if (IMSHit)
+      unlink(DestFile.c_str());
+   else
       Rename(DestFile,FinalFile);
-   }
+
    chmod(FinalFile.c_str(),0644);
    DestFile = FinalFile;
 }
@@ -1296,11 +1298,11 @@ bool pkgAcqArchive::QueueNext()
       
       string PkgFile = Parse.FileName();
       if(Parse.SHA256Hash() != "")
-        hash = HashString("SHA256", Parse.SHA256Hash());
+        ExpectedHash = HashString("SHA256", Parse.SHA256Hash());
       else if (Parse.SHA1Hash() != "")
-        hash = HashString("SHA1", Parse.SHA1Hash());
+        ExpectedHash = HashString("SHA1", Parse.SHA1Hash());
       else 
-        hash = HashString("MD5Sum", Parse.MD5Hash());
+        ExpectedHash = HashString("MD5Sum", Parse.MD5Hash());
       if (PkgFile.empty() == true)
         return _error->Error(_("The package index files are corrupted. No Filename: "
                              "field for package %s."),
@@ -1394,7 +1396,7 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string CalcHash,
    }
    
    // Check the hash
-   if(!hash.VerifyFile(DestFile))
+   if(ExpectedHash.toStr() != CalcHash)
    {
       Status = StatError;
       ErrorText = _("Hash Sum mismatch");
@@ -1492,10 +1494,10 @@ void pkgAcqArchive::Finished()
 // AcqFile::pkgAcqFile - Constructor                                   /*{{{*/
 // ---------------------------------------------------------------------
 /* The file is added to the queue */
-pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5,
+pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
                       unsigned long Size,string Dsc,string ShortDesc,
                       const string &DestDir, const string &DestFilename) :
-                       Item(Owner), hash(MD5)
+                       Item(Owner), ExpectedHash(Hash)
 {
    Retries = _config->FindI("Acquire::Retries",0);
    
@@ -1537,8 +1539,8 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string CalcHash,
 {
    Item::Done(Message,Size,CalcHash,Cnf);
 
-   // Check the md5
-   if(!hash.VerifyFile(DestFile))
+   // Check the hash
+   if(!ExpectedHash.empty() && ExpectedHash.toStr() != CalcHash)
    {
       Status = StatError;
       ErrorText = "Hash Sum mismatch";