diff options
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/acquire-item.cc | 14 | ||||
| -rw-r--r-- | apt-pkg/acquire-worker.cc | 12 |
2 files changed, 25 insertions, 1 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 1fc07ec05..7e1c5dad6 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -976,13 +976,25 @@ void pkgAcquire::Item::FailMessage(string const &Message) if (failreason == HASHSUM_MISMATCH) { out << "Hashes of received file:" << std::endl; + size_t hashes = 0; for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type) { std::string const tagname = std::string(*type) + "-Hash"; std::string const hashsum = LookupTag(Message, tagname.c_str()); - if (hashsum.empty() == false) + if (not hashsum.empty()) + { formatHashsum(out, HashString(*type, hashsum)); + ++hashes; + } } + if (hashes == 0) + for (char const *const *type = HashString::SupportedHashes(); *type != nullptr; ++type) + { + std::string const tagname = std::string("Alt-") + *type + "-Hash"; + std::string const hashsum = LookupTag(Message, tagname.c_str()); + if (not hashsum.empty()) + formatHashsum(out, HashString(*type, hashsum)); + } } auto const lastmod = LookupTag(Message, "Last-Modified", ""); if (lastmod.empty() == false) diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 035d8ce10..4c2acb5cc 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -457,6 +457,18 @@ bool pkgAcquire::Worker::RunMessages() FileFd file(filename, FileFd::ReadOnly, FileFd::None); calc.AddFD(file); ReceivedHashes = calc.GetHashStringList(); + for (auto const &h : ReceivedHashes) + { + std::string tagname; + if (AltFile) + tagname = "Alt-"; + tagname.append(h.HashType()).append("-Hash"); + if (not LookupTag(Message, tagname.c_str()).empty()) + continue; + if (not APT::String::Endswith(Message, "\n")) + Message.append("\n"); + Message.append(tagname).append(": ").append(h.HashValue()); + } } } |
