summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 23:23:04 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 23:23:04 +0200
commit8c4e1f97686c412f88bb57827a84b776626d9980 (patch)
tree8c71c01a75f5b9c393a3b9cadc6cf65b073a0af4 /ftparchive
parent1dab797ca6dc0357474675a0f132c962dee4a2c2 (diff)
* ftparchive/writer.cc:
- generate all checksums in one run over the file for Release
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/writer.cc34
1 files changed, 8 insertions, 26 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index c43e8f4b4..60db8b990 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -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>
@@ -1040,35 +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();
- }
-
+ CheckSums[NewFileName].SHA256 = hs.SHA256.Result();
if (DoSHA512 == true)
- {
- SHA512Summation SHA512;
- SHA512.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA512 = SHA512.Result();
- }
+ CheckSums[NewFileName].SHA512 = hs.SHA512.Result();
fd.Close();
-
+
return true;
}