[gnome-software/gnome-3-22] flatpak: Check the runtime exists before trying to launch the app



commit b492905853bba1ae44970a8a5fa00b09bc7b0c8c
Author: Richard Hughes <richard hughsie com>
Date:   Fri Sep 9 10:28:55 2016 +0100

    flatpak: Check the runtime exists before trying to launch the app
    
    Fixes half of https://bugzilla.gnome.org/show_bug.cgi?id=765055

 src/plugins/gs-flatpak.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index a189e4e..fcd5885 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -1788,6 +1788,7 @@ gs_flatpak_launch (GsFlatpak *self,
                   GCancellable *cancellable,
                   GError **error)
 {
+       GsApp *runtime;
        const gchar *branch = NULL;
 
        /* only process this app if was created by this plugin */
@@ -1798,13 +1799,33 @@ gs_flatpak_launch (GsFlatpak *self,
        branch = gs_app_get_flatpak_branch (app);
        if (branch == NULL)
                branch = "master";
-       return flatpak_installation_launch (self->installation,
-                                           gs_app_get_flatpak_name (app),
-                                           NULL,
-                                           branch,
-                                           NULL,
-                                           cancellable,
-                                           error);
+
+       /* check the runtime is installed */
+       runtime = gs_app_get_runtime (app);
+       if (runtime != NULL) {
+               if (!gs_plugin_refine_item_state (self, runtime, cancellable, error))
+                       return FALSE;
+               if (!gs_app_is_installed (runtime)) {
+                       g_set_error_literal (error,
+                                            GS_PLUGIN_ERROR,
+                                            GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                            "runtime is not installed");
+                       gs_plugin_cache_add (self->plugin, NULL, runtime);
+                       return FALSE;
+               }
+       }
+
+       /* launch the app */
+       if (!flatpak_installation_launch (self->installation,
+                                         gs_app_get_flatpak_name (app),
+                                         NULL,
+                                         branch,
+                                         NULL,
+                                         cancellable,
+                                         error)) {
+               return FALSE;
+       }
+       return TRUE;
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]