[gnome-software] flatpak: Create the ref display at runtime
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] flatpak: Create the ref display at runtime
- Date: Mon, 17 Jul 2017 19:14:30 +0000 (UTC)
commit e2719a849b42a32a7e42042d0c65cb2ac99f4a6d
Author: Richard Hughes <richard hughsie com>
Date: Mon Jul 17 19:25:10 2017 +0100
flatpak: Create the ref display at runtime
We can't set this from a xref for runtimes.
plugins/flatpak/gs-flatpak-app.c | 21 ++++++---------------
plugins/flatpak/gs-flatpak-app.h | 4 +---
plugins/flatpak/gs-flatpak.c | 26 ++++++++++----------------
3 files changed, 17 insertions(+), 34 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak-app.c b/plugins/flatpak/gs-flatpak-app.c
index 93e1dbb..73d52a0 100644
--- a/plugins/flatpak/gs-flatpak-app.c
+++ b/plugins/flatpak/gs-flatpak-app.c
@@ -31,7 +31,6 @@ struct _GsFlatpakApp
FlatpakRefKind ref_kind;
gchar *ref_arch;
gchar *ref_branch;
- gchar *ref_display;
gchar *ref_name;
gchar *commit;
gchar *object_id;
@@ -83,10 +82,6 @@ gs_flatpak_app_to_string (GsApp *app, GString *str)
gs_utils_append_key_value (str, 20, "flatpak::ref-branch",
flatpak_app->ref_branch);
}
- if (flatpak_app->ref_display != NULL) {
- gs_utils_append_key_value (str, 20, "flatpak::ref-display",
- flatpak_app->ref_display);
- }
if (flatpak_app->commit != NULL)
gs_utils_append_key_value (str, 20, "flatpak::commit",
flatpak_app->commit);
@@ -193,11 +188,15 @@ gs_flatpak_app_get_repo_url (GsApp *app)
return flatpak_app->repo_url;
}
-const gchar *
+gchar *
gs_flatpak_app_get_ref_display (GsApp *app)
{
GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
- return flatpak_app->ref_display;
+ return g_strdup_printf ("%s/%s/%s/%s",
+ gs_flatpak_app_get_ref_kind_as_str (app),
+ flatpak_app->ref_name,
+ flatpak_app->ref_arch,
+ flatpak_app->ref_branch);
}
void
@@ -270,13 +269,6 @@ gs_flatpak_app_set_repo_url (GsApp *app, const gchar *val)
_g_set_str (&flatpak_app->repo_url, val);
}
-void
-gs_flatpak_app_set_ref_display (GsApp *app, const gchar *val)
-{
- GsFlatpakApp *flatpak_app = GS_FLATPAK_APP (app);
- _g_set_str (&flatpak_app->ref_display, val);
-}
-
static void
gs_flatpak_app_finalize (GObject *object)
{
@@ -285,7 +277,6 @@ gs_flatpak_app_finalize (GObject *object)
g_object_unref (flatpak_app->runtime_repo);
g_free (flatpak_app->ref_arch);
g_free (flatpak_app->ref_branch);
- g_free (flatpak_app->ref_display);
g_free (flatpak_app->ref_name);
g_free (flatpak_app->commit);
g_free (flatpak_app->object_id);
diff --git a/plugins/flatpak/gs-flatpak-app.h b/plugins/flatpak/gs-flatpak-app.h
index 0336cbd..45e2aad 100644
--- a/plugins/flatpak/gs-flatpak-app.h
+++ b/plugins/flatpak/gs-flatpak-app.h
@@ -46,7 +46,7 @@ const gchar *gs_flatpak_app_get_ref_arch (GsApp *app);
const gchar *gs_flatpak_app_get_ref_branch (GsApp *app);
FlatpakRefKind gs_flatpak_app_get_ref_kind (GsApp *app);
const gchar *gs_flatpak_app_get_ref_kind_as_str (GsApp *app);
-const gchar *gs_flatpak_app_get_ref_display (GsApp *app);
+gchar *gs_flatpak_app_get_ref_display (GsApp *app);
const gchar *gs_flatpak_app_get_commit (GsApp *app);
const gchar *gs_flatpak_app_get_object_id (GsApp *app);
@@ -63,8 +63,6 @@ void gs_flatpak_app_set_ref_branch (GsApp *app,
const gchar *val);
void gs_flatpak_app_set_ref_kind (GsApp *app,
FlatpakRefKind ref_kind);
-void gs_flatpak_app_set_ref_display (GsApp *app,
- const gchar *val);
void gs_flatpak_app_set_commit (GsApp *app,
const gchar *val);
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index e6768fb..63d5d36 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -78,8 +78,6 @@ gs_plugin_refine_item_scope (GsFlatpak *self, GsApp *app)
static void
gs_flatpak_set_metadata (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
{
- g_autofree gchar *ref_display = NULL;
-
/* core */
gs_app_set_management_plugin (app, gs_plugin_get_name (self->plugin));
gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
@@ -97,10 +95,6 @@ gs_flatpak_set_metadata (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
if ((self->flags & GS_FLATPAK_FLAG_IS_TEMPORARY) == 0)
gs_flatpak_app_set_object_id (app, gs_flatpak_get_id (self));
- /* do this once for all objects */
- ref_display = flatpak_ref_format_ref (xref);
- gs_flatpak_app_set_ref_display (app, ref_display);
-
/* map the flatpak kind to the gnome-software kind */
if (flatpak_ref_get_kind (xref) == FLATPAK_REF_KIND_APP) {
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
@@ -2393,7 +2387,7 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
/* any extra bits */
for (guint i = 0; i < related->len; i++) {
FlatpakRelatedRef *xref_related = g_ptr_array_index (related, i);
- const gchar *xref_fake_str;
+ g_autofree gchar *ref_display = NULL;
g_autoptr(GsApp) app_tmp = NULL;
/* not included */
@@ -2402,12 +2396,12 @@ gs_flatpak_get_list_for_install (GsFlatpak *self, GsApp *app,
/* already installed? */
app_tmp = gs_flatpak_create_app (self, FLATPAK_REF (xref_related));
- xref_fake_str = gs_flatpak_app_get_ref_display (app_tmp);
- if (g_hash_table_contains (hash_installed, xref_fake_str)) {
- g_debug ("not adding related %s as already installed", xref_fake_str);
+ ref_display = gs_flatpak_app_get_ref_display (app_tmp);
+ if (g_hash_table_contains (hash_installed, ref_display)) {
+ g_debug ("not adding related %s as already installed", ref_display);
} else {
gs_app_set_origin (app_tmp, gs_app_get_origin (app));
- g_debug ("adding related %s for install", xref_fake_str);
+ g_debug ("adding related %s for install", ref_display);
gs_app_list_add (list, app_tmp);
}
}
@@ -2883,13 +2877,13 @@ gs_flatpak_update_app (GsFlatpak *self,
phelper->job_max = gs_app_list_length (list);
for (phelper->job_now = 0; phelper->job_now < phelper->job_max; phelper->job_now++) {
GsApp *app_tmp = gs_app_list_index (list, phelper->job_now);
- const gchar *xref_fake_str = NULL;
+ g_autofree gchar *ref_display = NULL;
g_autoptr(FlatpakInstalledRef) xref = NULL;
/* either install or update the ref */
- xref_fake_str = gs_flatpak_app_get_ref_display (app_tmp);
- if (!g_hash_table_contains (hash_installed, xref_fake_str)) {
- g_debug ("installing %s", xref_fake_str);
+ ref_display = gs_flatpak_app_get_ref_display (app_tmp);
+ if (!g_hash_table_contains (hash_installed, ref_display)) {
+ g_debug ("installing %s", ref_display);
xref = flatpak_installation_install (self->installation,
gs_app_get_origin (app_tmp),
gs_flatpak_app_get_ref_kind (app_tmp),
@@ -2899,7 +2893,7 @@ gs_flatpak_update_app (GsFlatpak *self,
gs_flatpak_progress_cb, phelper,
cancellable, error);
} else {
- g_debug ("updating %s", xref_fake_str);
+ g_debug ("updating %s", ref_display);
xref = flatpak_installation_update (self->installation,
FLATPAK_UPDATE_FLAGS_NONE,
gs_flatpak_app_get_ref_kind (app_tmp),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]