diff options
author | Matthias Klumpp <matthias@tenstral.net> | 2012-04-14 18:23:05 +0200 |
---|---|---|
committer | Matthias Klumpp <matthias@tenstral.net> | 2012-04-14 18:23:05 +0200 |
commit | f60d34b7b1da681f2838d70b67597b0a63e6a283 (patch) | |
tree | da84765770e4529a1b1a37922d99e4291fb35abe | |
parent | d7830866a5ec17cacfafd680f431f47fa73975d5 (diff) |
aptcc: Don't emit error if repo is empty
Closes LP: #879938
-rw-r--r-- | backends/aptcc/apt-intf.cpp | 8 | ||||
-rw-r--r-- | backends/aptcc/apt-messages.cpp | 24 | ||||
-rw-r--r-- | backends/aptcc/apt-messages.h | 3 | ||||
-rw-r--r-- | backends/aptcc/pk-backend-aptcc.cpp | 2 |
4 files changed, 27 insertions, 10 deletions
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp index db67aa86..bc84327a 100644 --- a/backends/aptcc/apt-intf.cpp +++ b/backends/aptcc/apt-intf.cpp @@ -248,7 +248,7 @@ pkgCache::VerIterator AptIntf::find_ver(const pkgCache::PkgIterator &pkg) } bool AptIntf::matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters) -{ +{ if (filters != 0) { const pkgCache::PkgIterator &pkg = ver.ParentPkg(); bool installed = false; @@ -257,7 +257,7 @@ bool AptIntf::matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters) if (pkg->CurrentState == pkgCache::State::Installed && pkg.CurrentVer() == ver) { installed = true; } - + // if we are on multiarch check also the arch filter if (m_isMultiArch && pk_bitfield_contain(filters, PK_FILTER_ENUM_ARCH)/* && !installed*/) { // don't emit the package if it does not match @@ -270,12 +270,12 @@ bool AptIntf::matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters) std::string str = ver.Section() == NULL ? "" : ver.Section(); std::string section, repo_section; - + size_t found; found = str.find_last_of("/"); section = str.substr(found + 1); repo_section = str.substr(0, found); - + if (pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED) && installed) { return false; } else if (pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED) && !installed) { diff --git a/backends/aptcc/apt-messages.cpp b/backends/aptcc/apt-messages.cpp index 33638573..c02bfcd0 100644 --- a/backends/aptcc/apt-messages.cpp +++ b/backends/aptcc/apt-messages.cpp @@ -28,23 +28,39 @@ using namespace std; -bool show_errors(PkBackend *backend, PkErrorEnum errorCode) +bool show_errors(PkBackend *backend, PkErrorEnum errorCode, bool errModify) { stringstream errors; + stringstream messages; + + PkMessageEnum messageCode = PK_MESSAGE_ENUM_UNKNOWN; + if (errorCode == PK_ERROR_ENUM_CANNOT_FETCH_SOURCES) + messageCode = PK_MESSAGE_ENUM_REPO_METADATA_DOWNLOAD_FAILED; string Err; while (_error->empty() == false) { bool Type = _error->PopMessage(Err); - if (Type == true) { - errors << "E: " << Err << endl; + + // Ugly workaround to demote the "repo not found" error message to a simple message + if ((errModify) && (Err.find("404 Not Found") != string::npos)) { + messages << "E: " << Err << endl; } else { - errors << "W: " << Err << endl; + if (Type == true) { + errors << "E: " << Err << endl; + } else { + errors << "W: " << Err << endl; + } } } if (!errors.str().empty()) { pk_backend_error_code(backend, errorCode, errors.str().c_str()); } + + if ((errModify) && (!messages.str().empty())) { + cout << "Emitting backend message:" << messages.str() << endl; + pk_backend_message(backend, messageCode, messages.str().c_str()); + } } bool show_warnings(PkBackend *backend, PkMessageEnum message) diff --git a/backends/aptcc/apt-messages.h b/backends/aptcc/apt-messages.h index 95666f3f..8c49988d 100644 --- a/backends/aptcc/apt-messages.h +++ b/backends/aptcc/apt-messages.h @@ -33,7 +33,8 @@ * Call the Packagekit error dialog */ bool show_errors(PkBackend *backend, - PkErrorEnum errorCode = PK_ERROR_ENUM_UNKNOWN); + PkErrorEnum errorCode = PK_ERROR_ENUM_UNKNOWN, + bool errModify = false); /** * Call the Packagekit message dialog diff --git a/backends/aptcc/pk-backend-aptcc.cpp b/backends/aptcc/pk-backend-aptcc.cpp index e6d51c68..2d38dea0 100644 --- a/backends/aptcc/pk-backend-aptcc.cpp +++ b/backends/aptcc/pk-backend-aptcc.cpp @@ -712,7 +712,7 @@ static gboolean pk_backend_refresh_cache_thread(PkBackend *backend) OpTextProgress Prog(*_config); if (Cache.BuildCaches(&Prog, true) == false) { if (_error->PendingError() == true) { - show_errors(backend, PK_ERROR_ENUM_CANNOT_FETCH_SOURCES); + show_errors(backend, PK_ERROR_ENUM_CANNOT_FETCH_SOURCES, true); } delete m_apt; return false; |