File 0009-Workaround-Don-t-refresh-repositories-each-time-for-.patch of Package PackageKit.import5521

From 9a704288d7e68cf4a8cbc6203616fdd5b62691be Mon Sep 17 00:00:00 2001
From: Duncan Mac-Vicar P <dmacvicar@suse.de>
Date: Wed, 19 Oct 2011 12:53:07 +0200
Subject: [PATCH] Workaround: Don't refresh repositories each time for
 operations called in batches like package search.

---
 backends/zypp/pk-backend-zypp.cpp |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index e885cb0..a893977 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1398,6 +1398,8 @@ pk_backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids)
 static gboolean
 backend_find_packages_thread (PkBackend *backend)
 {
+	static bool refreshed = false;
+
 	MIL << endl;
 	gchar **values;
 	const gchar *search;
@@ -1411,9 +1413,13 @@ backend_find_packages_thread (PkBackend *backend)
 	}
 
 	// refresh the repos before searching
-	if (!zypp_refresh_cache (backend, FALSE)) {
-		pk_backend_finished (backend);
-		return FALSE;
+	if (!refreshed) {
+		if (!zypp_refresh_cache (backend, FALSE)) {
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+		else
+			refreshed = true;
 	}
 
 	values = pk_backend_get_strv (backend, "search");
@@ -2075,10 +2081,15 @@ backend_download_packages_thread (PkBackend *backend)
 	MIL << endl;
 	gchar **package_ids;
 	gulong size = 0;
+	static bool refreshed = false;
 
-	if (!zypp_refresh_cache (backend, FALSE)) {
-		pk_backend_finished (backend);
-		return FALSE;
+	if (! refreshed) {
+		if (!zypp_refresh_cache (backend, FALSE)) {
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+		else
+			refreshed = true;
 	}
 
 	ZYpp::Ptr zypp;
-- 
1.7.6.4