summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-03-19 14:10:32 +0100
committerRichard Hughes <richard@hughsie.com>2020-01-23 12:28:34 +0100
commit47811d81f8f1e541517c506e604e3c574fda7eb9 (patch)
treed2b871e85d9532e763a6f13cc2ce827cd6a07527
parent16a85736ff7986bc42c690fb9bee42473ac24cae (diff)
aptcc: Only report errors if there are errors
Previously aptcc would report some warnings as errors. This way, it will drop any warning if there is no error. This matches the behavior of python-apt. As a bonus, we also log the entire message as a warning to the journal.
-rw-r--r--backends/aptcc/apt-intf.cpp7
-rw-r--r--backends/aptcc/apt-messages.cpp17
2 files changed, 13 insertions, 11 deletions
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 946a19555..f935dd410 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -2154,11 +2154,8 @@ void AptIntf::refreshCache()
return;
}
- // missing repo gpg signature would appear here
- if (_error->PendingError() == false && _error->empty() == false) {
- // TODO this shouldn't
- show_errors(m_job, PK_ERROR_ENUM_GPG_FAILURE);
- }
+ // TODO check what other errors could remain here and ensure the right error code is emitted for each
+ show_errors(m_job, PK_ERROR_ENUM_GPG_FAILURE, true);
}
void AptIntf::markAutoInstalled(const PkgList &pkgs)
diff --git a/backends/aptcc/apt-messages.cpp b/backends/aptcc/apt-messages.cpp
index 26cf0596a..e453f3563 100644
--- a/backends/aptcc/apt-messages.cpp
+++ b/backends/aptcc/apt-messages.cpp
@@ -32,27 +32,32 @@ using namespace std;
void show_errors(PkBackendJob *job, PkErrorEnum errorCode, bool errModify)
{
stringstream errors;
+ int errorCount = 0;
string Err;
while (_error->empty() == false) {
bool Type = _error->PopMessage(Err);
+ g_warning("%s", Err.c_str());
+
// Ugly workaround to demote the "repo not found" error message to a simple message
if ((errModify) && (Err.find("404 Not Found") != string::npos)) {
// TODO this should emit the regular
// PK_ERROR_ENUM_CANNOT_FETCH_SOURCES but do not fail the
// last-time-update
//! messages << "E: " << Err << endl;
+ continue;
+ }
+
+ if (Type == true) {
+ errors << "E: " << Err << endl;
+ errorCount++;
} else {
- if (Type == true) {
- errors << "E: " << Err << endl;
- } else {
- errors << "W: " << Err << endl;
- }
+ errors << "W: " << Err << endl;
}
}
- if (!errors.str().empty()) {
+ if (errorCount > 0) {
pk_backend_job_error_code(job,
errorCode,
"%s",