[packagekit] [PATCH 5/6] Refresh cache before geting upgrade and installing

Zhang Qiang qiang.z.zhang at intel.com
Tue Sep 7 02:03:02 PDT 2010


Refresh cache is necessary before executing get-updates and install
operations. With out this patch, pkcon get-updates/install would not 
work after modifying rpmdb using rpm or changing repo.

Related bug: http://bugs.meego.com/show_bug.cgi?id=2434
---
 backends/zypp/pk-backend-zypp.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 8c02983..7a0ca1e 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -551,6 +551,12 @@ backend_get_distro_upgrades_thread(PkBackend *backend)
 {
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 
+	// refresh the repos before checking for updates
+	if (!zypp_refresh_cache (backend, FALSE)) {
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
 	std::vector<zypp::parser::ProductFileData> result;
 	if (!zypp::parser::ProductFileReader::scanDir (zypp::functor::getAll (std::back_inserter (result)), "/etc/products.d")) {
 		return zypp_backend_finished_error (
@@ -983,6 +989,12 @@ backend_install_packages_thread (PkBackend *backend)
 {
 	gchar **package_ids;
 
+	// refresh the repos before installing packages
+	if (!zypp_refresh_cache (backend, FALSE)) {
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	pk_backend_set_percentage (backend, 0);
 
-- 
1.7.1.1




More information about the PackageKit mailing list