[gnome-software] trivial: Merge some common code



commit 3a067fae505c756c6d39b4094d2d85e73bfc34e8
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 21 13:51:41 2016 +0100

    trivial: Merge some common code

 src/gs-utils.c           |    1 +
 src/plugins/gs-flatpak.c |   55 +++++++++++----------------------------------
 2 files changed, 15 insertions(+), 41 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index f639d2e..9ccee9c 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -630,6 +630,7 @@ gs_utils_error_convert_gio (GError **perror)
        switch (error->code) {
        case G_IO_ERROR_FAILED:
        case G_IO_ERROR_TIMED_OUT:
+       case G_IO_ERROR_NOT_FOUND:
                error->code = GS_PLUGIN_ERROR_FAILED;
                break;
        case G_IO_ERROR_NOT_SUPPORTED:
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 21d60ce..83b95d5 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -450,12 +450,16 @@ gs_flatpak_refresh_appstream_remote (GsFlatpak *self,
                                  "flatpak::refresh-appstream{%s}",
                                  remote_name);
        g_assert (ptask != NULL);
-       return flatpak_installation_update_appstream_sync (self->installation,
-                                                          remote_name,
-                                                          NULL, /* arch */
-                                                          NULL, /* out_changed */
-                                                          cancellable,
-                                                          error);
+       if (!flatpak_installation_update_appstream_sync (self->installation,
+                                                        remote_name,
+                                                        NULL,
+                                                        NULL,
+                                                        cancellable,
+                                                        error)) {
+               gs_plugin_flatpak_error_convert (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 static gboolean
@@ -521,11 +525,8 @@ gs_flatpak_refresh_appstream (GsFlatpak *self, guint cache_age,
                                                           &error_local);
                if (!ret) {
                        if (g_error_matches (error_local,
-                                            G_IO_ERROR,
-                                            G_IO_ERROR_FAILED) ||
-                           g_error_matches (error_local,
-                                            G_IO_ERROR,
-                                            G_IO_ERROR_NOT_FOUND)) {
+                                            GS_PLUGIN_ERROR,
+                                            GS_PLUGIN_ERROR_FAILED)) {
                                g_debug ("Failed to get AppStream metadata: %s",
                                         error_local->message);
                                /* don't try to fetch this again until refresh() */
@@ -2406,33 +2407,6 @@ gs_flatpak_file_to_app_repo (GsFlatpak *self,
 }
 
 static gboolean
-gs_flatpak_update_appstream_for_remote (GsFlatpak *self,
-                                       const gchar *remote_name,
-                                       GCancellable *cancellable,
-                                       GError **error)
-{
-       g_autoptr(AsProfileTask) ptask = NULL;
-
-       /* search categories for the search term */
-       ptask = as_profile_start (gs_plugin_get_profile (self->plugin),
-                                 "flatpak::update-appstream{%s}",
-                                 remote_name);
-       g_assert (ptask != NULL);
-
-       /* get the new appstream data */
-       if (!flatpak_installation_update_appstream_sync (self->installation,
-                                                        remote_name,
-                                                        NULL,
-                                                        NULL,
-                                                        cancellable,
-                                                        error)) {
-               gs_plugin_flatpak_error_convert (error);
-               return FALSE;
-       }
-       return TRUE;
-}
-
-static gboolean
 gs_flatpak_file_to_app_ref (GsFlatpak *self,
                            GsAppList *list,
                            GFile *file,
@@ -2513,9 +2487,8 @@ gs_flatpak_file_to_app_ref (GsFlatpak *self,
        gs_app_set_origin_ui (app, origin_title);
 
        /* get the new appstream data */
-       if (!gs_flatpak_update_appstream_for_remote (self, remote_name,
-                                                    cancellable, error)) {
-               gs_plugin_flatpak_error_convert (error);
+       if (!gs_flatpak_refresh_appstream_remote (self, remote_name,
+                                                 cancellable, error)) {
                return FALSE;
        }
 


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