[gnome-software/wip/hughsie/flatpak-branch: 2/3] core: Set the	Flatpak branch from the bundle ID
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gnome-software/wip/hughsie/flatpak-branch: 2/3] core: Set the	Flatpak branch from the bundle ID
- Date: Tue, 25 Jun 2019 13:16:58 +0000 (UTC)
commit 7b1dc0b4f6dea56cea716d5bb65c30490febc400
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 25 13:49:37 2019 +0100
    core: Set the Flatpak branch from the bundle ID
    
    It's important to set this before early as the branch is used in the unique ID.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/684
 plugins/core/gs-appstream.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index de54a20d..b6f60f9c 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -834,6 +834,22 @@ gs_appstream_refine_app (GsPlugin *plugin,
                        const gchar *kind = xb_node_get_attr (bundle, "type");
                        gs_app_add_source (app, xb_node_get_text (bundle));
                        gs_app_set_bundle_kind (app, as_bundle_kind_from_string (kind));
+
+                       /* get the type/name/arch/branch */
+                       if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_FLATPAK) {
+                               g_auto(GStrv) split = g_strsplit (xb_node_get_text (bundle), "/", -1);
+                               if (g_strv_length (split) != 4) {
+                                       g_set_error (error,
+                                                    GS_PLUGIN_ERROR,
+                                                    GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                                    "invalid ID %s for a flatpak ref",
+                                                    xb_node_get_text (bundle));
+                                       return FALSE;
+                               }
+
+                               /* we only need the branch for the unique ID */
+                               gs_app_set_branch (app, split[3]);
+                       }
                }
        }
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]