summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-04-24 10:35:08 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-04-25 15:35:52 +0200
commit30979dd7616105302f06af82f419eb62d7b613f8 (patch)
tree1bacc60224a2a26ef4fe70fb4a5db8232051f84d /apt-pkg/acquire-item.cc
parent0340069cc4709a18ba117090763d9f263de999a9 (diff)
show more details for "Writing more data" errors, too
They are the small brothers of the hashsum mismatch, so they deserve a similar treatment even through we have for architectual reasons not a much to display as for hashsum mismatches for now.
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r--apt-pkg/acquire-item.cc63
1 files changed, 42 insertions, 21 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index aeadbcfc7..ceed5a510 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -679,35 +679,59 @@ void pkgAcquire::Item::Failed(string const &Message,pkgAcquire::MethodConfig con
Dequeue();
}
+ string const FailReason = LookupTag(Message, "FailReason");
+ enum { MAXIMUM_SIZE_EXCEEDED, HASHSUM_MISMATCH, OTHER } failreason = OTHER;
+ if ( FailReason == "MaximumSizeExceeded")
+ failreason = MAXIMUM_SIZE_EXCEEDED;
+ else if (Status == StatAuthError)
+ failreason = HASHSUM_MISMATCH;
+
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)
+ switch (failreason)
+ {
+ case HASHSUM_MISMATCH:
+ out << _("Hash Sum mismatch") << std::endl;
+ break;
+ case MAXIMUM_SIZE_EXCEEDED:
+ case OTHER:
+ out << LookupTag(Message, "Message") << std::endl;
+ break;
+ }
+ auto const ExpectedHashes = GetExpectedHashes();
+ if (ExpectedHashes.empty() == false)
{
- 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 << "Hashes of expected file:" << std::endl;
+ for (auto const &hs: ExpectedHashes)
+ out << " - " << hs.toStr() << std::endl;
+ }
+ if (failreason == HASHSUM_MISMATCH)
+ {
+ 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;
}
- 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);
- else if (Status == StatAuthError)
- RenameOnError(HashSumMismatch);
+ switch (failreason)
+ {
+ case MAXIMUM_SIZE_EXCEEDED: RenameOnError(MaximumSizeExceeded); break;
+ case HASHSUM_MISMATCH: RenameOnError(HashSumMismatch); break;
+ case OTHER: break;
+ }
if (FailReason.empty() == false)
ReportMirrorFailureToCentral(*this, FailReason, ErrorText);
@@ -800,7 +824,6 @@ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const
{
case HashSumMismatch:
errtext = _("Hash Sum mismatch");
- Status = StatAuthError;
break;
case SizeMismatch:
errtext = _("Size mismatch");
@@ -821,7 +844,6 @@ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const
break;
case MaximumSizeExceeded:
// the method is expected to report a good error for this
- Status = StatError;
break;
case PDiffError:
// no handling here, done by callers
@@ -1791,9 +1813,8 @@ 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")
+ if (TransactionManager == nullptr || TransactionManager->MetaIndexParser == nullptr ||
+ Status != StatAuthError)
return;
ErrorText.append("Release file created at: ");