summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib/hashes.cc')
-rw-r--r--apt-pkg/contrib/hashes.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 4481321c4..41a0037cd 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -129,6 +129,13 @@ APT_PURE bool HashString::empty() const /*{{{*/
return (Type.empty() || Hash.empty());
}
/*}}}*/
+APT_PURE bool HashString::usable() const /*{{{*/
+{
+ return (
+ (Type != "Checksum-FileSize") &&
+ (Type != "MD5Sum")
+ );
+}
std::string HashString::toStr() const /*{{{*/
{
return Type + ":" + Hash;
@@ -151,10 +158,10 @@ bool HashStringList::usable() const /*{{{*/
std::string const forcedType = _config->Find("Acquire::ForceHash", "");
if (forcedType.empty() == true)
{
- // FileSize alone isn't usable
- for (std::vector<HashString>::const_iterator hs = list.begin(); hs != list.end(); ++hs)
- if (hs->HashType() != "Checksum-FileSize")
- return true;
+ // See if there is at least one usable hash
+ for (auto const &hs: list)
+ if (hs.usable())
+ return true;
return false;
}
return find(forcedType) != NULL;