[packagekit] packagekit: Branch 'master' - 5 commits

Richard Hughes hughsient at kemper.freedesktop.org
Fri Oct 5 15:57:57 PDT 2007


 backends/conary/helpers/conaryBackend.py |   15 +++++---
 backends/conary/pk-backend-conary.c      |    4 +-
 src/pk-engine.c                          |   57 +++++++++++++++++++++++++++++--
 src/pk-transaction-db.c                  |    9 +++-
 4 files changed, 75 insertions(+), 10 deletions(-)

New commits:
diff-tree 73416cc05fa844a72e3adf6465722e5ba37c26c6 (from b9e5e2c9723550f1321222fbc85532a11ed9bd6c)
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 5 23:48:29 2007 +0100

    don't put a LIMIT on the transaction viewer when we pass 0

diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index 69c1b95..3da818b 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -193,8 +193,13 @@ pk_transaction_db_get_list (PkTransactio
 	g_return_val_if_fail (tdb != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), FALSE);
 
-	statement = g_strdup_printf ("SELECT transaction_id, timespec, succeeded, duration, role, data "
-				     "FROM transactions ORDER BY transaction_id DESC LIMIT %i", limit);
+	if (limit == 0) {
+		statement = g_strdup ("SELECT transaction_id, timespec, succeeded, duration, role, data "
+				      "FROM transactions ORDER BY transaction_id");
+	} else {
+		statement = g_strdup_printf ("SELECT transaction_id, timespec, succeeded, duration, role, data "
+					     "FROM transactions ORDER BY transaction_id DESC LIMIT %i", limit);
+	}
 	pk_transaction_db_sql_statement (tdb, statement);
 	g_free (statement);
 
diff-tree b9e5e2c9723550f1321222fbc85532a11ed9bd6c (from 3e1b2d521f029dee8f4b36d8447921d769fcd3ed)
Author: Ken VanDine <ken at vandine.org>
Date:   Fri Oct 5 15:53:14 2007 -0400

    Disable get_depends for now

diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 9efba66..90c6623 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -187,6 +187,7 @@ backend_update_system (PkBackend *backen
 /**
  * backend_get_depends:
  */
+/**
 static void
 backend_get_depends (PkBackend *backend, const gchar *package_id)
 {
@@ -194,6 +195,7 @@ backend_get_depends (PkBackend *backend,
 	pk_backend_allow_interrupt (backend, TRUE);
 	pk_backend_spawn_helper (backend, "get-depends.py", package_id, NULL);
 }
+ */
 
 PK_BACKEND_OPTIONS (
 	"Conary",				/* description */
@@ -204,7 +206,7 @@ PK_BACKEND_OPTIONS (
 	backend_get_groups,			/* get_groups */
 	backend_get_filters,			/* get_filters */
 	NULL,					/* cancel */
-	backend_get_depends,			/* get_depends */
+	NULL,					/* get_depends */
 	NULL,					/* get_description */
 	NULL,					/* get_requires */
 	NULL,					/* get_update_detail */
diff-tree 3e1b2d521f029dee8f4b36d8447921d769fcd3ed (from parents)
Merge: 1316297cda356c688fe46782cd680abd5e900b37 3d829d0049373a6dc011802966d241c5ab2fdd73
Author: Ken VanDine <ken at vandine.org>
Date:   Fri Oct 5 15:48:30 2007 -0400

    Merge branch 'master' of git+ssh://kvandine@git.packagekit.org/srv/git/PackageKit

diff-tree 1316297cda356c688fe46782cd680abd5e900b37 (from d400909022826a8ae2621d735ee71c1cc1ead2e4)
Author: Ken VanDine <ken at vandine.org>
Date:   Fri Oct 5 15:48:18 2007 -0400

    Improved logic for get_depends

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 98914ca..f59f5d6 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -142,16 +142,21 @@ class PackageKitConaryBackend(PackageKit
         name, version, flavor, installed = self._findPackage(package_id)
 
         if name:
-            if installed:
+            if installed == INFO_INSTALLED:
                 self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                     'Package already installed')
 
-            updJob, suggMap = self._do_package_update(name, version, flavor,
+            else:
+                updJob, suggMap = self._do_package_update(name, version, flavor,
                                                       apply=False)
 
-            for what, need in suggMap:
-                id = self.get_package_id(need[0], need[1], need[2])
-                self.package(id, False, '')
+                for what, need in suggMap:
+                    id = self.get_package_id(need[0], need[1], need[2])
+                    depInstalled = self.check_installed(need[0])
+                    if depInstalled == INFO_INSTALLED:
+                        self.package(id, INFO_INSTALLED, '')
+                    else:
+                        self.package(id, INFO_AVAILABLE, '')
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                 'Package was not found')
diff-tree 3d829d0049373a6dc011802966d241c5ab2fdd73 (from 83cac883f97e67e31064c23a356eafe80069a22c)
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 5 20:45:08 2007 +0100

    keep a list of updates so we only have to call GetUpdates when the cache is cold. This should reduce the workloads on backends

diff --git a/src/pk-engine.c b/src/pk-engine.c
index 613e194..b19c7ed 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -43,6 +43,7 @@
 
 #include <pk-debug.h>
 #include <pk-task-common.h>
+#include <pk-package-list.h>
 #include <pk-enum.h>
 
 #include "pk-backend-internal.h"
@@ -66,6 +67,7 @@ struct PkEnginePrivate
 	PkTransactionList	*transaction_list;
 	PkTransactionDb		*transaction_db;
 	PkTransactionItem	*sync_item;
+	PkPackageList		*updates_cache;
 };
 
 enum {
@@ -465,7 +467,21 @@ pk_engine_finished_cb (PkBackend *backen
 		g_warning ("Backend not set yet!");
 		return;
 	}
-	exit_text = pk_exit_enum_to_text (exit);
+
+	/* get what the role was */
+	pk_backend_get_role (item->backend, &role, NULL);
+
+	/* copy this into the cache if we are getting updates */
+	if (role == PK_ROLE_ENUM_GET_UPDATES) {
+		if (engine->priv->updates_cache != NULL) {
+			pk_debug ("unreffing updates cache");
+			g_object_unref (engine->priv->updates_cache);
+		}
+		engine->priv->updates_cache = item->package_list;
+		pk_debug ("reffing updates cache");
+		g_object_ref (engine->priv->updates_cache);
+		g_object_add_weak_pointer (G_OBJECT (engine->priv->updates_cache), (gpointer) &engine->priv->updates_cache);
+	}
 
 	/* find the length of time we have been running */
 	time = pk_backend_get_runtime (backend);
@@ -481,13 +497,13 @@ pk_engine_finished_cb (PkBackend *backen
 	pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
 
 	/* could the update list have changed? */
-	pk_backend_get_role (item->backend, &role, NULL);
 	if (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
 	    role == PK_ROLE_ENUM_UPDATE_PACKAGE) {
 		pk_debug ("emitting updates-changed tid:%s", item->tid);
 		g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, item->tid);
 	}
 
+	exit_text = pk_exit_enum_to_text (exit);
 	pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, exit_text, (guint) time);
 	g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, (guint) time);
 
@@ -733,6 +749,13 @@ pk_engine_refresh_cache (PkEngine *engin
 		return FALSE;
 	}
 
+	/* we unref the update cache if it exists */
+	if (engine->priv->updates_cache != NULL) {
+		pk_debug ("unreffing updates cache");
+		g_object_unref (engine->priv->updates_cache);
+		engine->priv->updates_cache = NULL;
+	}
+
 	ret = pk_backend_refresh_cache (item->backend, force);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -773,6 +796,28 @@ pk_engine_get_updates (PkEngine *engine,
 		return FALSE;
 	}
 
+	/* try and reuse cache */
+	if (engine->priv->updates_cache != NULL) {
+		PkPackageListItem *package;
+		GPtrArray *plist;
+		guint i;
+		guint length;
+
+		plist = pk_package_list_get_buffer (engine->priv->updates_cache);
+		pk_warning ("we have cached data (%i) we could use!", plist->len);
+
+		/* emulate the backend */
+		pk_backend_set_role (item->backend, PK_ROLE_ENUM_GET_UPDATES);
+		length = plist->len;
+		for (i=0; i<length; i++) {
+			package = g_ptr_array_index (plist, i);
+			pk_engine_package_cb (item->backend, package->info, package->package_id, package->summary, engine);
+		}
+		pk_engine_finished_cb (item->backend, PK_EXIT_ENUM_SUCCESS, engine);
+		pk_engine_item_delete (engine, item);
+		return TRUE;
+	}
+
 	ret = pk_backend_get_updates (item->backend);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2105,6 +2150,9 @@ pk_engine_init (PkEngine *engine)
 	engine->priv->timer = g_timer_new ();
 	engine->priv->backend = NULL;
 
+	/* we save a cache of the latest update lists sowe can do cached responses */
+	engine->priv->updates_cache = NULL;
+
 	engine->priv->transaction_list = pk_transaction_list_new ();
 	g_signal_connect (engine->priv->transaction_list, "changed",
 			  G_CALLBACK (pk_engine_transaction_list_changed_cb), engine);
@@ -2154,6 +2202,11 @@ pk_engine_finalize (GObject *object)
 	g_object_unref (engine->priv->transaction_list);
 	g_object_unref (engine->priv->transaction_db);
 
+	if (engine->priv->updates_cache != NULL) {
+		pk_debug ("unreffing updates cache");
+		g_object_unref (engine->priv->updates_cache);
+	}
+
 	G_OBJECT_CLASS (pk_engine_parent_class)->finalize (object);
 }
 



More information about the PackageKit mailing list