Просмотр исходного кода

* apt-pkg/acquire-worker.cc:
- only pass a hash if we actually got one from the method
* methods/copy.cc:
- take hashes here too (*sigh*)

Michael Vogt лет назад: 19
Родитель
Сommit
95f4572796
2 измененных файлов с 10 добавлено и 2 удалено
  1. 3 1
      apt-pkg/acquire-worker.cc
  2. 7 1
      methods/copy.cc

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

@@ -273,7 +273,9 @@ bool pkgAcquire::Worker::RunMessages()
 	    if(!expectedHash.empty()) 
 	    {
 	       string hashTag = expectedHash.HashType()+"-Hash";
-	       RecivedHash = expectedHash.HashType() + ":" + LookupTag(Message, hashTag.c_str());
+	       string hashSum = LookupTag(Message, hashTag.c_str());
+	       if(!hashSum.empty())
+		  RecivedHash = expectedHash.HashType() + ":" + hashSum;
 	       if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
 	       {
 		  clog << "201 URI Done: " << Owner->DescURI() << endl

+ 7 - 1
methods/copy.cc

@@ -12,6 +12,8 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
+#include <apt-pkg/fileutl.h>
 
 #include <sys/stat.h>
 #include <utime.h>
@@ -78,7 +80,11 @@ bool CopyMethod::Fetch(FetchItem *Itm)
       To.OpFail();
       return _error->Errno("utime",_("Failed to set modification time"));
    }
-   
+
+   Hashes Hash;
+   FileFd Fd(Res.Filename, FileFd::ReadOnly);
+   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Res.TakeHashes(Hash);
    URIDone(Res);
    return true;
 }