[gnome-software] flatpak: Don't return network-related error on refine if offline



commit d3c1fe45984e92f3da1ef0ee0b2423d4ad1abcca
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Mon Jul 2 12:55:09 2018 +0200

    flatpak: Don't return network-related error on refine if offline
    
    If the machine is offline and fetching the metadata results in an error,
    simply print a warning, instead of returning the error which results as
    an error banner.
    
    This is in order to prevent the very annoying recurring error banner
    when e.g. searching, or going into an app's details while offline.
    
    Reworked slightly by Philip Withnall <withnall endlessm com>.

 plugins/flatpak/gs-flatpak.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 0ab70e8a..f1355e5d 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2205,10 +2205,21 @@ gs_flatpak_refine_app_unlocked (GsFlatpak *self,
 
        /* size */
        if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) {
+               g_autoptr(GError) error_local = NULL;
                if (!gs_plugin_refine_item_size (self, app,
-                                                cancellable, error)) {
-                       g_prefix_error (error, "failed to get size: ");
-                       return FALSE;
+                                                cancellable, &error_local)) {
+                       if (!gs_plugin_get_network_available (self->plugin) &&
+                           g_error_matches (error_local, GS_PLUGIN_ERROR,
+                                            GS_PLUGIN_ERROR_NO_NETWORK)) {
+                               g_debug ("failed to get size while "
+                                        "refining app %s: %s",
+                                        gs_app_get_unique_id (app),
+                                        error_local->message);
+                       } else {
+                               g_prefix_error (&error_local, "failed to get size: ");
+                               g_propagate_error (error, g_steal_pointer (&error_local));
+                               return FALSE;
+                       }
                }
        }
 
@@ -2225,10 +2236,21 @@ gs_flatpak_refine_app_unlocked (GsFlatpak *self,
        /* permissions */
        if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME ||
            flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS) {
+               g_autoptr(GError) error_local = NULL;
                if (!gs_plugin_refine_item_metadata (self, app,
-                                                    cancellable, error)) {
-                       g_prefix_error (error, "failed to get permissions: ");
-                       return FALSE;
+                                                    cancellable, &error_local)) {
+                       if (!gs_plugin_get_network_available (self->plugin) &&
+                           g_error_matches (error_local, GS_PLUGIN_ERROR,
+                                            GS_PLUGIN_ERROR_NO_NETWORK)) {
+                               g_debug ("failed to get permissions while "
+                                        "refining app %s: %s",
+                                        gs_app_get_unique_id (app),
+                                        error_local->message);
+                       } else {
+                               g_prefix_error (&error_local, "failed to get permissions: ");
+                               g_propagate_error (error, g_steal_pointer (&error_local));
+                               return FALSE;
+                       }
                }
        }
 


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