[gnome-software/wip/kalev/gnome-3-22: 65/96] trivial: Fix some error handling when installing runtimes



commit 7c1f7611480244c60aa7cfc13d76671ad16061db
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 21 18:30:08 2017 +0000

    trivial: Fix some error handling when installing runtimes

 src/plugins/gs-flatpak.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 9c02dfd..4f4648a 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -2090,7 +2090,6 @@ install_runtime_for_app (GsFlatpak *self,
 
                data = gs_flatpak_fetch_remote_metadata (self, app, cancellable, error);
                if (data == NULL) {
-                       gs_app_set_state_recover (app);
                        return FALSE;
                }
 
@@ -2098,6 +2097,8 @@ install_runtime_for_app (GsFlatpak *self,
                runtime_new = gs_flatpak_create_runtime_from_metadata (self, app,
                                                                       str, len,
                                                                       error);
+               if (runtime_new == NULL)
+                       return FALSE;
                gs_app_set_update_runtime (app, runtime_new);
        }
 
@@ -2108,15 +2109,12 @@ install_runtime_for_app (GsFlatpak *self,
 
        /* the runtime could come from a different remote to the app */
        if (!gs_refine_item_metadata (self, runtime, cancellable, error)) {
-               gs_app_set_state_recover (app);
                return FALSE;
        }
        if (!gs_plugin_refine_item_origin (self, runtime, cancellable, error)) {
-               gs_app_set_state_recover (app);
                return FALSE;
        }
        if (!gs_plugin_refine_item_state (self, runtime, cancellable, error)) {
-               gs_app_set_state_recover (app);
                return FALSE;
        }
        if (gs_app_get_state (runtime) == AS_APP_STATE_UNKNOWN) {
@@ -2125,7 +2123,6 @@ install_runtime_for_app (GsFlatpak *self,
                             GS_PLUGIN_ERROR_NOT_SUPPORTED,
                             "Failed to find runtime %s",
                             gs_app_get_source_default (runtime));
-               gs_app_set_state_recover (app);
                return FALSE;
        }
 
@@ -2148,7 +2145,6 @@ install_runtime_for_app (GsFlatpak *self,
                                                     cancellable, error);
                if (xref == NULL) {
                        gs_app_set_state_recover (runtime);
-                       gs_app_set_state_recover (app);
                        return FALSE;
                }
                gs_app_set_state (runtime, AS_APP_STATE_INSTALLED);
@@ -2171,8 +2167,8 @@ gs_flatpak_app_install (GsFlatpak *self,
        g_autoptr(FlatpakInstalledRef) xref = NULL;
 
        /* ensure we have metadata and state */
-       if (!gs_flatpak_refine_app (self, app, 0, cancellable,
-                                   error))
+       if (!gs_flatpak_refine_app (self, app, GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+                                   cancellable, error))
                return FALSE;
 
        /* install */
@@ -2188,8 +2184,10 @@ gs_flatpak_app_install (GsFlatpak *self,
 
        /* install required runtime if not already installed */
        if (gs_app_get_kind (app) == AS_APP_KIND_DESKTOP &&
-           !install_runtime_for_app (self, app, cancellable, error))
+           !install_runtime_for_app (self, app, cancellable, error)) {
+               gs_app_set_state_recover (app);
                return FALSE;
+       }
 
        if (g_strcmp0 (gs_app_get_flatpak_file_type (app), "flatpak") == 0) {
                if (gs_app_get_local_file (app) == NULL) {
@@ -2254,8 +2252,10 @@ gs_flatpak_update_app (GsFlatpak *self,
 
        /* install required runtime if not already installed */
        if (gs_app_get_kind (app) == AS_APP_KIND_DESKTOP &&
-           !install_runtime_for_app (self, app, cancellable, error))
+           !install_runtime_for_app (self, app, cancellable, error)) {
+               gs_app_set_state_recover (app);
                return FALSE;
+       }
 
        xref = flatpak_installation_update (self->installation,
                                            FLATPAK_UPDATE_FLAGS_NONE,


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