]> git.saurik.com Git - apt.git/blobdiff - ftparchive/writer.cc
merged from the debian-experimental2 branch
[apt.git] / ftparchive / writer.cc
index eb8938b9594708bc69335fc3216a5b5740c55dba..60db8b9907a949541e2edc08efe78da93bd9b495 100644 (file)
@@ -19,8 +19,7 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/md5.h>
-#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha2.h>
+#include <apt-pkg/hashes.h>
 #include <apt-pkg/deblistparser.h>
 
 #include <sys/types.h>
@@ -64,6 +63,7 @@ FTWScanner::FTWScanner(string const &Arch): Arch(Arch)
    DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
    DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
    DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+   DoSHA512 = _config->FindB("APT::FTPArchive::SHA512",true);
 }
                                                                        /*}}}*/
 // FTWScanner::Scanner - FTW Scanner                                   /*{{{*/
@@ -1039,33 +1039,18 @@ bool ReleaseWriter::DoPackage(string FileName)
 
    CheckSums[NewFileName].size = fd.Size();
 
+   Hashes hs;
+   hs.AddFD(fd.Fd(), 0, DoMD5, DoSHA1, DoSHA256, DoSHA512);
    if (DoMD5 == true)
-   {
-      MD5Summation MD5;
-      MD5.AddFD(fd.Fd(), fd.Size());
-      CheckSums[NewFileName].MD5 = MD5.Result();
-      fd.Seek(0);
-   }
+      CheckSums[NewFileName].MD5 = hs.MD5.Result();
    if (DoSHA1 == true)
-   {
-      SHA1Summation SHA1;
-      SHA1.AddFD(fd.Fd(), fd.Size());
-      CheckSums[NewFileName].SHA1 = SHA1.Result();
-      fd.Seek(0);
-   }
+      CheckSums[NewFileName].SHA1 = hs.SHA1.Result();
    if (DoSHA256 == true)
-   {
-      SHA256Summation SHA256;
-      SHA256.AddFD(fd.Fd(), fd.Size());
-      CheckSums[NewFileName].SHA256 = SHA256.Result();
-   }
-
-   SHA256Summation SHA512;
-   SHA256.AddFD(fd.Fd(), fd.Size());
-   CheckSums[NewFileName].SHA512 = SHA512.Result();
-
+      CheckSums[NewFileName].SHA256 = hs.SHA256.Result();
+   if (DoSHA512 == true)
+      CheckSums[NewFileName].SHA512 = hs.SHA512.Result();
    fd.Close();
-   
+
    return true;
 }