[gnome-software/wip/kalev/download-step: 6/10] systemd updates: Fix various issues with refine



commit 2c4f9676bc315b71197db771186973cede2eea89
Author: Kalev Lember <klember redhat com>
Date:   Tue Oct 23 11:06:45 2018 +0200

    systemd updates: Fix various issues with refine
    
    Re-read /var/lib/PackageKit/prepared-update before refining apps, so
    that we can be sure that the data is up to date. We can't rely on the
    async file monitor to fire as the refine may be called directly after
    updating /var/lib/PackageKit/prepared-update and before the file monitor
    gets a chance to fire.
    
    While at this, this commit also makes sure that we refine related apps
    for proxy apps (OS Updates).

 plugins/packagekit/gs-plugin-systemd-updates.c | 44 +++++++++++++++++++-------
 1 file changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-systemd-updates.c b/plugins/packagekit/gs-plugin-systemd-updates.c
index 449a9726..95cdd0a5 100644
--- a/plugins/packagekit/gs-plugin-systemd-updates.c
+++ b/plugins/packagekit/gs-plugin-systemd-updates.c
@@ -141,30 +141,50 @@ gs_plugin_systemd_trigger_changed_cb (GFileMonitor *monitor,
        gs_plugin_systemd_updates_refresh_is_triggered (plugin, NULL);
 }
 
-gboolean
-gs_plugin_refine_app (GsPlugin *plugin,
-                     GsApp *app,
-                     GsPluginRefineFlags flags,
-                     GCancellable *cancellable,
-                     GError **error)
+static void
+gs_plugin_systemd_refine_app (GsPlugin *plugin, GsApp *app)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
        const gchar *package_id;
 
-       /* not now */
-       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) == 0)
-               return TRUE;
-
        /* only process this app if was created by this plugin */
        if (g_strcmp0 (gs_app_get_management_plugin (app), "packagekit") != 0)
-               return TRUE;
+               return;
 
        /* the package is already downloaded */
        package_id = gs_app_get_source_id_default (app);
        if (package_id == NULL)
-               return TRUE;
+               return;
        if (g_hash_table_lookup (priv->hash_prepared, package_id) != NULL)
                gs_app_set_size_download (app, 0);
+}
+
+gboolean
+gs_plugin_refine (GsPlugin *plugin,
+                  GsAppList *list,
+                  GsPluginRefineFlags flags,
+                  GCancellable *cancellable,
+                  GError **error)
+{
+       /* not now */
+       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) == 0)
+               return TRUE;
+
+       /* re-read /var/lib/PackageKit/prepared-update */
+       if (!gs_plugin_systemd_update_cache (plugin, error))
+               return FALSE;
+
+       for (guint i = 0; i < gs_app_list_length (list); i++) {
+               GsApp *app = gs_app_list_index (list, i);
+               GsAppList *related = gs_app_get_related (app);
+               /* refine the app itself */
+               gs_plugin_systemd_refine_app (plugin, app);
+               /* and anything related for proxy apps */
+               for (guint j = 0; j < gs_app_list_length (related); j++) {
+                       GsApp *app_related = gs_app_list_index (related, j);
+                       gs_plugin_systemd_refine_app (plugin, app_related);
+               }
+       }
 
        return TRUE;
 }


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