[gnome-software] Use a background PackageKit transaction when downloading upgrades
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use a background PackageKit transaction when downloading upgrades
- Date: Thu, 21 Apr 2016 07:47:51 +0000 (UTC)
commit d8473ce45d6725dcc3634b681d0dcb091865ab8a
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 21 08:39:38 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 5dabc58..5241fb0 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -59,7 +59,6 @@ gs_plugin_initialize (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
priv->task = pk_task_new ();
- pk_client_set_background (PK_CLIENT (priv->task), FALSE);
pk_client_set_interactive (PK_CLIENT (priv->task), FALSE);
pk_client_set_cache_age (PK_CLIENT (priv->task), G_MAXUINT);
}
@@ -141,6 +140,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 (priv->task), FALSE);
+
/* do sync call */
filter = pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED,
PK_FILTER_ENUM_NEWEST,
@@ -185,6 +187,9 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
ptask = as_profile_start_literal (gs_plugin_get_profile (plugin),
"packagekit::add-sources-related");
filter = pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED,
@@ -245,6 +250,9 @@ gs_plugin_add_sources (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
/* ask PK for the repo details */
filter = pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_SOURCE,
PK_FILTER_ENUM_NOT_SUPPORTED,
@@ -301,6 +309,9 @@ gs_plugin_app_source_enable (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
/* do sync call */
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_enable (PK_CLIENT (priv->task),
@@ -341,6 +352,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 (priv->task), FALSE);
+
/* we enable the repo */
if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) {
@@ -508,6 +522,9 @@ gs_plugin_app_source_disable (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
/* do sync call */
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_enable (PK_CLIENT (priv->task),
@@ -539,6 +556,9 @@ gs_plugin_app_source_remove (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
/* do sync call */
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
results = pk_client_repo_remove (PK_CLIENT (priv->task),
@@ -614,6 +634,9 @@ gs_plugin_app_remove (GsPlugin *plugin,
return FALSE;
}
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (priv->task), FALSE);
+
/* do the action */
gs_app_set_state (app, AS_APP_STATE_REMOVING);
results = pk_task_remove_packages_sync (priv->task,
@@ -663,6 +686,9 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
return FALSE;
}
+ /* low priority background operation */
+ pk_client_set_background (PK_CLIENT (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 (priv->task),
@@ -701,6 +727,9 @@ gs_plugin_add_search_files (GsPlugin *plugin,
data.plugin = plugin;
data.ptask = NULL;
+ /* high priority foreground operation */
+ pk_client_set_background (PK_CLIENT (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,
@@ -738,6 +767,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 (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]