[gnome-software/wip/hughsie/wildcarded-metadata: 2/2] Copy metadata from wildcard GsApp objects to concrete GsApps
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/wildcarded-metadata: 2/2] Copy metadata from wildcard GsApp objects to concrete GsApps
- Date: Mon, 15 Oct 2018 09:40:18 +0000 (UTC)
commit c4c3b62dd054b8285b1565912c75bc36d4c0cd2b
Author: Richard Hughes <richard hughsie com>
Date: Sun Oct 14 09:43:12 2018 +0100
Copy metadata from wildcard GsApp objects to concrete GsApps
This allows us to set a wildcard that matches on some metadata (for instance,
GnomeSoftware::FeatureTile-css) and this allows us to preserve the data without
having to re-resolve the metadata in the concrete GsApp.
This allows us to ignore the problem where the system appstream plugin is no
longer refining flatpaks, and thus higher priority GsApps were not getting the
system-defined feature tile CSS metadata set.
lib/gs-app.c | 21 +++++++++++++++++++++
lib/gs-app.h | 3 +++
plugins/core/gs-appstream.c | 1 +
plugins/core/gs-plugin-appstream.c | 1 +
plugins/flatpak/gs-flatpak.c | 1 +
5 files changed, 27 insertions(+)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 38298a12..b0876744 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -4537,4 +4537,25 @@ gs_app_get_packaging_format (GsApp *app)
return g_strdup (bundle_kind_ui);
}
+/**
+ * gs_app_subsume_metadata:
+ * @app: a #GsApp
+ * @donor: another #GsApp
+ *
+ * Copies any metadata from @donor to @app.
+ *
+ * Since: 3.32
+ **/
+void
+gs_app_subsume_metadata (GsApp *app, GsApp *donor)
+{
+ GsAppPrivate *priv = gs_app_get_instance_private (donor);
+ g_autoptr(GList) keys = g_hash_table_get_keys (priv->metadata);
+ for (GList *l = keys; l != NULL; l = l->next) {
+ const gchar *key = l->data;
+ const gchar *value = gs_app_get_metadata_item (donor, key);
+ gs_app_set_metadata (app, key, value);
+ }
+}
+
/* vim: set noexpandtab: */
diff --git a/lib/gs-app.h b/lib/gs-app.h
index f07ed372..f7c7e5b4 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -356,6 +356,9 @@ gboolean gs_app_is_installed (GsApp *app);
gboolean gs_app_is_updatable (GsApp *app);
gchar *gs_app_get_origin_ui (GsApp *app);
gchar *gs_app_get_packaging_format (GsApp *app);
+void gs_app_subsume_metadata (GsApp *app,
+ GsApp *donor);
+
G_END_DECLS
#endif /* __GS_APP_H */
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 3fb8284f..a9c7f945 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1088,6 +1088,7 @@ gs_appstream_add_featured (GsPlugin *plugin,
continue;
app = gs_app_new (as_app_get_id (item));
gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+ gs_appstream_copy_metadata (app, item);
gs_app_list_add (list, app);
}
return TRUE;
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index c3eaf245..b38dd1e8 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -591,6 +591,7 @@ gs_plugin_refine_wildcard (GsPlugin *plugin,
new = gs_appstream_create_app (plugin, item, error);
if (new == NULL)
return FALSE;
+ gs_app_subsume_metadata (new, app);
gs_app_list_add (list, new);
}
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index faabf721..12595bc6 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1991,6 +1991,7 @@ gs_flatpak_refine_wildcard (GsFlatpak *self, GsApp *app,
gs_flatpak_claim_app (self, new);
if (!gs_flatpak_refine_app (self, new, flags, cancellable, error))
return FALSE;
+ gs_app_subsume_metadata (new, app);
gs_app_list_add (list, new);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]