summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-03-12 20:29:04 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-04-25 15:35:52 +0200
commit0340069cc4709a18ba117090763d9f263de999a9 (patch)
tree7a94ceb4e5baebae96bbb06b0248b8500863b191 /apt-pkg/acquire-item.cc
parent6563390031a88ffd85308ac3c26ea9d10bc6bc99 (diff)
show more details for "Hash Sum mismatch" errors
Users tend to report these errors with just this error message… not very actionable and hard to figure out if this is a temporary or 'permanent' mirror-sync issue or even the occasional apt bug. Showing the involved hashsums and modification times should help in triaging these kind of bugs – and eventually we will have less of them via by-hash. The subheaders aren't marked for translation for now as they are technical glibberish and probably easier to deal with if not translated. After all, our iconic "Hash Sum mismatch" is translated at least. These additions were proposed in #817240 by Peter Palfrader.
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r--apt-pkg/acquire-item.cc60
1 files changed, 47 insertions, 13 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 474c0a0f2..aeadbcfc7 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -650,8 +650,6 @@ APT_CONST bool pkgAcquire::Item::IsTrusted() const /*{{{*/
fetch this object */
void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig const * const Cnf)
{
- if(ErrorText.empty())
- ErrorText = LookupTag(Message,"Message");
if (QueueCounter <= 1)
{
/* This indicates that the file is not available right now but might
@@ -681,18 +679,37 @@ void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig con
Dequeue();
}
+ if(ErrorText.empty())
+ {
+ if (Status == StatAuthError)
+ {
+ std::ostringstream out;
+ out << _("Hash Sum mismatch") << std::endl;
+ out << "Hashes of expected file:" << std::endl;
+ for (auto const &hs: GetExpectedHashes())
+ out << " - " << hs.toStr() << std::endl;
+ out << "Hashes of received file:" << std::endl;
+ 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)
+ out << " - " << HashString(*type, hashsum).toStr() << std::endl;
+ }
+ out << "Last modification reported: " << LookupTag(Message, "Last-Modified", "<none>") << std::endl;
+ ErrorText = out.str();
+ }
+ else
+ ErrorText = LookupTag(Message,"Message");
+ }
+
string const FailReason = LookupTag(Message, "FailReason");
if (FailReason == "MaximumSizeExceeded")
- {
RenameOnError(MaximumSizeExceeded);
- ReportMirrorFailureToCentral(*this, FailReason, ErrorText);
- }
else if (Status == StatAuthError)
- {
RenameOnError(HashSumMismatch);
- ReportMirrorFailureToCentral(*this, "HashChecksumFailure", ErrorText);
- }
- else if (FailReason.empty() == false)
+
+ if (FailReason.empty() == false)
ReportMirrorFailureToCentral(*this, FailReason, ErrorText);
else
ReportMirrorFailureToCentral(*this, ErrorText, ErrorText);
@@ -1771,6 +1788,23 @@ pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
{
}
/*}}}*/
+void pkgAcqBaseIndex::Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf)/*{{{*/
+{
+ pkgAcquire::Item::Failed(Message, Cnf);
+ if (TransactionManager == nullptr || ErrorText.empty() ||
+ TransactionManager->MetaIndexParser == nullptr ||
+ LookupTag(Message, "FailReason") != "HashSumMismatch")
+ return;
+
+ ErrorText.append("Release file created at: ");
+ auto const timespec = TransactionManager->MetaIndexParser->GetDate();
+ if (timespec == 0)
+ ErrorText.append("<unknown>");
+ else
+ ErrorText.append(TimeRFC1123(timespec));
+ ErrorText.append("\n");
+}
+ /*}}}*/
pkgAcqBaseIndex::~pkgAcqBaseIndex() {}
// AcqDiffIndex::AcqDiffIndex - Constructor /*{{{*/
@@ -2210,7 +2244,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
/*}}}*/
void pkgAcqDiffIndex::Failed(string const &Message,pkgAcquire::MethodConfig const * const Cnf)/*{{{*/
{
- Item::Failed(Message,Cnf);
+ pkgAcqBaseIndex::Failed(Message,Cnf);
Status = StatDone;
if(Debug)
@@ -2291,7 +2325,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
/*}}}*/
void pkgAcqIndexDiffs::Failed(string const &Message,pkgAcquire::MethodConfig const * const Cnf)/*{{{*/
{
- Item::Failed(Message,Cnf);
+ pkgAcqBaseIndex::Failed(Message,Cnf);
Status = StatDone;
DestFile = GetKeepCompressedFileName(GetPartialFileNameFromURI(Target.URI), Target);
@@ -2496,7 +2530,7 @@ void pkgAcqIndexMergeDiffs::Failed(string const &Message,pkgAcquire::MethodConfi
if(Debug)
std::clog << "pkgAcqIndexMergeDiffs failed: " << Desc.URI << " with " << Message << std::endl;
- Item::Failed(Message,Cnf);
+ pkgAcqBaseIndex::Failed(Message,Cnf);
Status = StatDone;
// check if we are the first to fail, otherwise we are done here
@@ -2734,7 +2768,7 @@ string pkgAcqIndex::Custom600Headers() const
// AcqIndex::Failed - getting the indexfile failed /*{{{*/
void pkgAcqIndex::Failed(string const &Message,pkgAcquire::MethodConfig const * const Cnf)
{
- Item::Failed(Message,Cnf);
+ pkgAcqBaseIndex::Failed(Message,Cnf);
// authorisation matches will not be fixed by other compression types
if (Status != StatAuthError)