[gnome-software/gnome-3-20] Use a background PackageKit transaction when downloading upgrades



commit b67a8e0456ff078d82e1bceb59011d8daead24f9
Author: Richard Hughes <richard hughsie com>
Date:   Thu Apr 21 08:43:33 2016 +0100

    Use a background PackageKit transaction when downloading upgrades
    
    This means any other foreground PackageKit transaction from any user will
    auto-cancel the background task and it will *not* be restarted automatically.

 src/plugins/gs-plugin-packagekit.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index 3e5ca1c..14b53e1 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -60,7 +60,6 @@ gs_plugin_initialize (GsPlugin *plugin)
        /* create private area */
        plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
        plugin->priv->task = pk_task_new ();
-       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
        pk_client_set_interactive (PK_CLIENT (plugin->priv->task), FALSE);
        pk_client_set_cache_age (PK_CLIENT (plugin->priv->task), G_MAXUINT);
 }
@@ -140,6 +139,9 @@ gs_plugin_add_installed (GsPlugin *plugin,
        /* update UI as this might take some time */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED,
                                         PK_FILTER_ENUM_NEWEST,
@@ -183,6 +185,9 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        ptask = as_profile_start_literal (plugin->profile, "packagekit::add-sources-related");
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED,
                                         PK_FILTER_ENUM_NEWEST,
@@ -241,6 +246,9 @@ gs_plugin_add_sources (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* ask PK for the repo details */
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_SOURCE,
                                         PK_FILTER_ENUM_NOT_SUPPORTED,
@@ -296,6 +304,9 @@ gs_plugin_app_source_enable (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        results = pk_client_repo_enable (PK_CLIENT (plugin->priv->task),
@@ -335,6 +346,9 @@ gs_plugin_app_install (GsPlugin *plugin,
        if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
                return TRUE;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* we enable the repo */
        if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) {
 
@@ -501,6 +515,9 @@ gs_plugin_app_source_disable (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        results = pk_client_repo_enable (PK_CLIENT (plugin->priv->task),
@@ -531,6 +548,9 @@ gs_plugin_app_source_remove (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        results = pk_client_repo_remove (PK_CLIENT (plugin->priv->task),
@@ -605,6 +625,9 @@ gs_plugin_app_remove (GsPlugin *plugin,
                return FALSE;
        }
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do the action */
        gs_app_set_state (app, AS_APP_STATE_REMOVING);
        results = pk_task_remove_packages_sync (plugin->priv->task,
@@ -657,6 +680,9 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
                return FALSE;
        }
 
+       /* low priority background operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), TRUE);
+
        /* ask PK to download enough packages to upgrade the system */
        gs_app_set_state (app, AS_APP_STATE_INSTALLING);
        results = pk_client_upgrade_system (PK_CLIENT (plugin->priv->task),
@@ -694,6 +720,9 @@ gs_plugin_add_search_files (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST,
@@ -730,6 +759,9 @@ gs_plugin_add_search_what_provides (GsPlugin *plugin,
        data.plugin = plugin;
        data.ptask = NULL;
 
+       /* high priority foreground operation */
+       pk_client_set_background (PK_CLIENT (plugin->priv->task), FALSE);
+
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        filter = pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST,


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