From 28ee7f19b865c32ce1b03cc0afa26983a0208693 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 9 Nov 2016 23:32:02 +0100 Subject: rename Checksum-FileSize to Filesize in hashsum mismatch Some people do not recognize the field value with such an arcane name and/or expect it to refer to something different (e.g. #839257). We can't just rename it internally as its an avoidance strategy as such fieldname existed previously with less clear semantics, but we can spare the general public from this implementation detail. --- apt-pkg/acquire-item.cc | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'apt-pkg/acquire-item.cc') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 9c6f85093..163743ce0 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -748,6 +748,18 @@ APT_CONST bool pkgAcquire::Item::IsTrusted() const /*{{{*/ // --------------------------------------------------------------------- /* We return to an idle state if there are still other queues that could fetch this object */ +static void formatHashsum(std::ostream &out, HashString const &hs) +{ + auto const type = hs.HashType(); + if (type == "Checksum-FileSize") + out << " - Filesize"; + else + out << " - " << type; + out << ':' << hs.HashValue(); + if (hs.usable() == false) + out << " [weak]"; + out << std::endl; +} void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig const * const Cnf) { if (QueueCounter <= 1) @@ -819,12 +831,7 @@ void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig con { out << "Hashes of expected file:" << std::endl; for (auto const &hs: ExpectedHashes) - { - out << " - " << hs.toStr(); - if (hs.usable() == false) - out << " [weak]"; - out << std::endl; - } + formatHashsum(out, hs); } if (failreason == HASHSUM_MISMATCH) { @@ -834,16 +841,12 @@ void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig con std::string const tagname = std::string(*type) + "-Hash"; std::string const hashsum = LookupTag(Message, tagname.c_str()); if (hashsum.empty() == false) - { - auto const hs = HashString(*type, hashsum); - out << " - " << hs.toStr(); - if (hs.usable() == false) - out << " [weak]"; - out << std::endl; - } + formatHashsum(out, HashString(*type, hashsum)); } - out << "Last modification reported: " << LookupTag(Message, "Last-Modified", "") << std::endl; } + auto const lastmod = LookupTag(Message, "Last-Modified", ""); + if (lastmod.empty() == false) + out << "Last modification reported: " << lastmod << std::endl; } ErrorText = out.str(); } -- cgit v1.2.3