File 0007-only-load-repositories-once.patch of Package PackageKit.import5521

From 724c2bf491a34a800604b2ac333906e656c46a2e Mon Sep 17 00:00:00 2001
From: Duncan Mac-Vicar P <dmacvicar@suse.de>
Date: Tue, 26 Jul 2011 11:20:51 +0200
Subject: [PATCH 7/8] only load repositories once

---
 backends/zypp/zypp-utils.cpp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 8fc69bd..4b84300 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -192,8 +192,11 @@ zypp_is_valid_repo (PkBackend *backend, RepoInfo repo)
 ResPool
 zypp_build_pool (PkBackend *backend, gboolean include_local)
 {
+	static gboolean repos_loaded = FALSE;
+
 	ZYpp::Ptr zypp = get_zypp (backend);
 
+	// the target is loaded or unloaded on request
 	if (include_local) {
 		// FIXME have to wait for fix in zypp (repeated loading of target)
 		if (sat::Pool::instance().reposFind( sat::Pool::systemRepoAlias() ).solvablesEmpty ())
@@ -211,6 +214,10 @@ zypp_build_pool (PkBackend *backend, gboolean include_local)
 		}
 	}
 
+	// we only load repositories once.
+	if (repos_loaded)
+		return zypp->pool();
+
 	// Add resolvables from enabled repos
 	RepoManager manager;
 	list<RepoInfo> repos;
@@ -230,7 +237,9 @@ zypp_build_pool (PkBackend *backend, gboolean include_local)
                         //FIXME see above, skip already cached repos
                         if (sat::Pool::instance().reposFind( repo.alias ()) == Repository::noRepository)
                                 manager.loadFromCache (repo);
+
 		}
+		repos_loaded = true;
 	} catch (const repo::RepoNoAliasException &ex) {
                 g_error ("Can't figure an alias to look in cache");
         } catch (const repo::RepoNotCachedException &ex) {
-- 
1.7.6.4