[gnome-software/gnome-3-22] Remove any addons that have the same source as the parent app
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Remove any addons that have the same source as the parent app
- Date: Thu, 8 Dec 2016 11:44:31 +0000 (UTC)
commit e6b8ae60b0ad207e9eb8b63da87acaca99e75ea2
Author: Richard Hughes <richard hughsie com>
Date: Tue Dec 6 14:53:44 2016 +0000
Remove any addons that have the same source as the parent app
Sometimes applications install plugins with metainfo files as part of the main
application. This is a problem because we currently strip out any addons from
the AppStream metadata whilst building that have the same pkgname as the parent
application.
If we can stop doing this it will save ~30ms per installed metainfo file not in
the appstream data file as we no longer have to use PackageKit at startup to
look up the package name. This requires the opposite change in appstream-builder
but this gnome-software patch is harmless with the old builder logic.
src/gs-app-private.h | 2 ++
src/gs-app.c | 19 +++++++++++++++++++
src/gs-plugin-loader.c | 29 +++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app-private.h b/src/gs-app-private.h
index 9fb8391..608c420 100644
--- a/src/gs-app-private.h
+++ b/src/gs-app-private.h
@@ -34,6 +34,8 @@ void gs_app_set_priority (GsApp *app,
guint gs_app_get_priority (GsApp *app);
void gs_app_set_unique_id (GsApp *app,
const gchar *unique_id);
+void gs_app_remove_addon (GsApp *app,
+ GsApp *addon);
G_END_DECLS
diff --git a/src/gs-app.c b/src/gs-app.c
index 1167884..9b1cde8 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -2652,6 +2652,25 @@ gs_app_add_addon (GsApp *app, GsApp *addon)
}
/**
+ * gs_app_remove_addon:
+ * @app: a #GsApp
+ * @addon: a #GsApp
+ *
+ * Removes an addon from the list of application addons.
+ *
+ * Since: 3.22
+ **/
+void
+gs_app_remove_addon (GsApp *app, GsApp *addon)
+{
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&app->mutex);
+ g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (GS_IS_APP (addon));
+ g_ptr_array_remove (app->addons, addon);
+ g_hash_table_remove (app->addons_hash, gs_app_get_id (addon));
+}
+
+/**
* gs_app_get_related:
* @app: a #GsApp
*
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 21eef5c..1f88681 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -630,6 +630,35 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
goto out;
}
+ /* remove any addons that have the same source as the parent app */
+ for (i = 0; i < gs_app_list_length (list); i++) {
+ g_autoptr(GPtrArray) to_remove = g_ptr_array_new ();
+ GsApp *app = gs_app_list_index (list, i);
+ GPtrArray *addons = gs_app_get_addons (app);
+
+ /* find any apps with the same source */
+ const gchar *pkgname_parent = gs_app_get_source_default (app);
+ if (pkgname_parent == NULL)
+ continue;
+ for (guint j = 0; j < addons->len; j++) {
+ GsApp *addon = g_ptr_array_index (addons, j);
+ if (g_strcmp0 (gs_app_get_source_default (addon),
+ pkgname_parent) == 0) {
+ g_debug ("%s has the same pkgname of %s as %s",
+ gs_app_get_unique_id (app),
+ pkgname_parent,
+ gs_app_get_unique_id (addon));
+ g_ptr_array_add (to_remove, addon);
+ }
+ }
+
+ /* remove any addons with the same source */
+ for (guint j = 0; j < to_remove->len; j++) {
+ GsApp *addon = g_ptr_array_index (to_remove, j);
+ gs_app_remove_addon (app, addon);
+ }
+ }
+
out:
/* now emit all the changed signals */
for (i = 0; i < gs_app_list_length (freeze_list); i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]