]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/hashes.cc
Compare size before data when ordering cache bucket entries
[apt.git] / apt-pkg / contrib / hashes.cc
index 5c0023dc726414d31a080a36c61c6d769669219a..662c2bf8ba64b58a432ec17f721fe079282f24f1 100644 (file)
@@ -129,11 +129,21 @@ APT_PURE bool HashString::empty() const                                   /*{{{*/
    return (Type.empty() || Hash.empty());
 }
                                                                        /*}}}*/
+
+APT_PURE static bool IsConfigured(const char *name, const char *what)
+{
+   std::string option;
+   strprintf(option, "APT::Hashes::%s::%s", name, what);
+   return _config->FindB(option, false);
+}
+
 APT_PURE bool HashString::usable() const                               /*{{{*/
 {
    return (
       (Type != "Checksum-FileSize") &&
-      (Type != "MD5Sum")
+      (Type != "MD5Sum") &&
+      (Type != "SHA1") &&
+      !IsConfigured(Type.c_str(), "Untrusted")
    );
 }
                                                                        /*}}}*/
@@ -302,6 +312,8 @@ public:
 // Hashes::Add* - Add the contents of data or FD                       /*{{{*/
 bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size)
 {
+   if (Size == 0)
+      return true;
    bool Res = true;
 APT_IGNORE_DEPRECATED_PUSH
    if ((d->CalcHashes & MD5SUM) == MD5SUM)