summaryrefslogtreecommitdiff
path: root/apt-private/acqprogress.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2024-11-22 21:02:46 +0000
committerJulian Andres Klode <jak@debian.org>2024-11-22 21:02:46 +0000
commit731c8bf96c06abce3797859e5d784e2caaf137c3 (patch)
tree76174389ed4e5a9f61cf8dad20a06ceede8bd8cb /apt-private/acqprogress.cc
parent1a03ebc11982f052259a6b677ebc520f8d47cb81 (diff)
parenta732f74400147a9993358b4778335715a0d5e20e (diff)
Merge branch 'fix/collect-ignored-errors' into 'main'
Collect unprinted Ign errors for display in Err output See merge request apt-team/apt!405
Diffstat (limited to 'apt-private/acqprogress.cc')
-rw-r--r--apt-private/acqprogress.cc58
1 files changed, 41 insertions, 17 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index b4b16e6a9..b8b540e75 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -123,39 +123,63 @@ void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm)
AssignItemID(Itm);
clearLastLine();
- bool ShowErrorText = true;
+ bool ShowErrorText = false;
if (Itm.Owner->Status == pkgAcquire::Item::StatDone || Itm.Owner->Status == pkgAcquire::Item::StatIdle)
{
// TRANSLATOR: Very short word to be displayed for files in 'apt-get update'
// which failed to download, but the error is ignored (compare "Err:")
ioprintf(out, _("Ign:%lu %s"), Itm.Owner->ID, Itm.Description.c_str());
- if (Itm.Owner->ErrorText.empty() ||
- _config->FindB("Acquire::Progress::Ignore::ShowErrorText", false) == false)
- ShowErrorText = false;
+ if (not Itm.Owner->ErrorText.empty())
+ {
+ if (_config->FindB("Acquire::Progress::Ignore::ShowErrorText", false))
+ ShowErrorText = true;
+ else
+ {
+ if (auto const ignored = IgnoredErrorTexts.find(Itm.Owner->ID); ignored != IgnoredErrorTexts.end())
+ {
+ if (std::find(ignored->second.begin(), ignored->second.end(), Itm.Owner->ErrorText) == ignored->second.end())
+ ignored->second.emplace_back(Itm.Owner->ErrorText);
+ }
+ else
+ IgnoredErrorTexts.emplace(Itm.Owner->ID, std::vector<std::string>{Itm.Owner->ErrorText});
+ }
+ }
}
else
{
// TRANSLATOR: Very short word to be displayed for files in 'apt-get update'
// which failed to download and the error is critical (compare "Ign:")
ioprintf(out, _("Err:%lu %s"), Itm.Owner->ID, Itm.Description.c_str());
+ ShowErrorText = true;
}
- if (ShowErrorText)
+ if (ShowErrorText && not Itm.Owner->ErrorText.empty())
{
- std::string::size_type line_start = 0;
- std::string::size_type line_end;
- while ((line_end = Itm.Owner->ErrorText.find_first_of("\n\r", line_start)) != std::string::npos) {
- out << std::endl << " " << Itm.Owner->ErrorText.substr(line_start, line_end - line_start);
- line_start = Itm.Owner->ErrorText.find_first_not_of("\n\r", line_end + 1);
- if (line_start == std::string::npos)
- break;
+ auto const printErrorText = [](std::ostream &out, std::string_view errortext) {
+ while (not errortext.empty())
+ {
+ auto const line_end = errortext.find_first_of("\n\r");
+ out << "\n " << errortext.substr(0, line_end);
+ if (line_end == std::string_view::npos)
+ break;
+ errortext.remove_prefix(line_end);
+ auto const line_start = errortext.find_first_not_of("\n\r");
+ if (line_start == std::string_view::npos)
+ break;
+ errortext.remove_prefix(line_start);
+ }
+ };
+ if (auto const ignored = IgnoredErrorTexts.find(Itm.Owner->ID); ignored != IgnoredErrorTexts.end())
+ {
+ for (auto const &text : ignored->second)
+ printErrorText(out, text);
+ if (std::find(ignored->second.begin(), ignored->second.end(), Itm.Owner->ErrorText) == ignored->second.end())
+ printErrorText(out, Itm.Owner->ErrorText);
}
- if (line_start == 0)
- out << std::endl << " " << Itm.Owner->ErrorText;
- else if (line_start != std::string::npos)
- out << std::endl << " " << Itm.Owner->ErrorText.substr(line_start);
+ else
+ printErrorText(out, Itm.Owner->ErrorText);
}
- out << std::endl;
+ out << '\n' << std::flush;
Update = true;
}