[gnome-software/gnome-3-22] Don't refresh flatpak repos if there are no permissions



commit af8f2c968bebebb6ad3d1174c2a36d1bfb853aa0
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 1 15:12:50 2016 +0000

    Don't refresh flatpak repos if there are no permissions
    
    (cherry picked from commit 653b106b226f8f8a289df462df7feff31145b1f3)

 src/plugins/gs-plugin-flatpak-system.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index 013eaa0..7b9a2eb 100644
--- a/src/plugins/gs-plugin-flatpak-system.c
+++ b/src/plugins/gs-plugin-flatpak-system.c
@@ -77,6 +77,24 @@ gboolean
 gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+       const gchar *action_id = "org.freedesktop.Flatpak.appstream-update";
+       g_autoptr(GPermission) permission = NULL;
+
+       /* if we can't update the AppStream database system-wide don't even
+        * pull the data as we can't do anything with it */
+       permission = gs_utils_get_permission (action_id);
+       if (permission != NULL) {
+               gboolean ret = g_permission_get_allowed (permission) ||
+                               g_permission_get_can_acquire (permission);
+               if (!ret) {
+                       g_set_error (error,
+                                    GS_PLUGIN_ERROR,
+                                    GS_PLUGIN_ERROR_NOT_SUPPORTED,
+                                    "no way to update using %s", action_id);
+                       return FALSE;
+               }
+       }
+
        return gs_flatpak_setup (priv->flatpak, cancellable, error);
 }
 


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