summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-method.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2013-08-19 00:00:23 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-05-09 13:06:27 +0200
commitb3501edb7091ca3aa6c2d6d96dc667b8161dd2b9 (patch)
tree078d7f11b418e900e21f009275e74b51918c5961 /apt-pkg/acquire-method.cc
parent1262d35895c930f3fa49d7b4182cdd7a4a841f74 (diff)
use HashStringList in the acquire system
It is not very extensible to have the supported Hashes hardcoded everywhere and especially if it is part of virtual method names. It is also possible that a method does not support the 'best' hash (yet), so we might end up not being able to verify a file even though we have a common subset of supported hashes. And those are just two of the cases in which it is handy to have a more dynamic selection. The downside is that this is a MAJOR API break, but the HashStringList has a string constructor for compatibility, so with a bit of luck the few frontends playing with the acquire system directly are okay.
Diffstat (limited to 'apt-pkg/acquire-method.cc')
-rw-r--r--apt-pkg/acquire-method.cc39
1 files changed, 16 insertions, 23 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 746c553f1..58d214068 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -147,6 +147,16 @@ void pkgAcqMethod::URIStart(FetchResult &Res)
// AcqMethod::URIDone - A URI is finished /*{{{*/
// ---------------------------------------------------------------------
/* */
+static void printHashStringList(HashStringList const * const list)
+{
+ for (HashStringList::const_iterator hash = list->begin(); hash != list->end(); ++hash)
+ {
+ // very old compatibility name for MD5Sum
+ if (hash->HashType() == "MD5Sum")
+ std::cout << "MD5-Hash: " << hash->HashValue() << "\n";
+ std::cout << hash->HashType() << "-Hash: " << hash->HashValue() << "\n";
+ }
+}
void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
{
if (Queue == 0)
@@ -164,15 +174,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
if (Res.LastModified != 0)
std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
- if (Res.MD5Sum.empty() == false)
- std::cout << "MD5-Hash: " << Res.MD5Sum << "\n"
- << "MD5Sum-Hash: " << Res.MD5Sum << "\n";
- if (Res.SHA1Sum.empty() == false)
- std::cout << "SHA1-Hash: " << Res.SHA1Sum << "\n";
- if (Res.SHA256Sum.empty() == false)
- std::cout << "SHA256-Hash: " << Res.SHA256Sum << "\n";
- if (Res.SHA512Sum.empty() == false)
- std::cout << "SHA512-Hash: " << Res.SHA512Sum << "\n";
+ printHashStringList(&Res.Hashes);
+
if (UsedMirror.empty() == false)
std::cout << "UsedMirror: " << UsedMirror << "\n";
if (Res.GPGVOutput.empty() == false)
@@ -200,15 +203,8 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
if (Alt->LastModified != 0)
std::cout << "Alt-Last-Modified: " << TimeRFC1123(Alt->LastModified) << "\n";
- if (Alt->MD5Sum.empty() == false)
- std::cout << "Alt-MD5-Hash: " << Alt->MD5Sum << "\n";
- if (Alt->SHA1Sum.empty() == false)
- std::cout << "Alt-SHA1-Hash: " << Alt->SHA1Sum << "\n";
- if (Alt->SHA256Sum.empty() == false)
- std::cout << "Alt-SHA256-Hash: " << Alt->SHA256Sum << "\n";
- if (Alt->SHA512Sum.empty() == false)
- std::cout << "Alt-SHA512-Hash: " << Alt->SHA512Sum << "\n";
-
+ printHashStringList(&Alt->Hashes);
+
if (Alt->IMSHit == true)
std::cout << "Alt-IMS-Hit: true\n";
}
@@ -442,12 +438,9 @@ pkgAcqMethod::FetchResult::FetchResult() : LastModified(0),
// ---------------------------------------------------------------------
/* This hides the number of hashes we are supporting from the caller.
It just deals with the hash class. */
-void pkgAcqMethod::FetchResult::TakeHashes(Hashes &Hash)
+void pkgAcqMethod::FetchResult::TakeHashes(class Hashes &Hash)
{
- MD5Sum = Hash.MD5.Result();
- SHA1Sum = Hash.SHA1.Result();
- SHA256Sum = Hash.SHA256.Result();
- SHA512Sum = Hash.SHA512.Result();
+ Hashes = Hash.GetHashStringList();
}
/*}}}*/
void pkgAcqMethod::Dequeue() { /*{{{*/