summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/hashes.cc15
-rw-r--r--apt-pkg/contrib/hashes.h1
2 files changed, 12 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;
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 0e6ff9ef1..74024befd 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -68,6 +68,7 @@ class HashString
// helper
std::string toStr() const; // convert to str as "type:hash"
bool empty() const;
+ bool usable() const;
bool operator==(HashString const &other) const;
bool operator!=(HashString const &other) const;